Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[EuiDataGrid][BugFix]: Fix visible overflowing truncated text #7793

Conversation

mgadewoll
Copy link
Contributor

@mgadewoll mgadewoll commented May 28, 2024

Summary

closes #7780

This PR aims to fix an issue on EuiDataGrid cells where truncation is applied with line-clamp when the following props are set:

rowHeightsOptions: {
  defaultHeight: {
     lineCount: 1,
  }
}

This results in the overflown text being still visible partially. This depends on available space created by the fontSize and cellPadding passed via gridStyle.

before
Screenshot 2024-05-28 at 15 06 58

To ensure the correct space is considered by line-clamp, we need to separate the styles for padding from the truncation step while still ensuring that the padding is included in the height calculation.

after
Screenshot 2024-05-28 at 15 23 20

This PR also adds a more specific story for row height checks: https://eui.elastic.co/pr_7793/storybook/index.html?path=/story/tabular-content-euidatagrid--row-height

QA

  • open storybook on production and on this PR branch and set the following props:
    • change fontSize on gridStyles to "s"
    {
      "fontSize": "s",
      "cellPadding": "l",
      "border": "all",
      "stripes": false,
      "header": "shade",
      "footer": "overline",
      "stickyFooter": true,
      "rowHover": "highlight",
      "rowClasses": {}
    }
    
    • change defaultHeight on rowHeightsOptions to {"lineCount": 1}
    {
      "defaultHeight": {
        "lineCount": 1
      },
      "rowHeights": {}
    }
    
    • verify that the on the fixed branch storybook the truncated text after the ellipsis is not visible
    • verify no other visual changes have been introduced

General checklist

  • Browser QA
    • Checked in both light and dark modes
    • Checked in mobile
    • Checked in Chrome, Safari, Edge, and Firefox
    • Checked for accessibility including keyboard-only and screenreader modes
  • Docs site QA -N/A
  • Code quality checklist
    • Added or updated VRT images
  • Release checklist
    • A changelog entry exists and is marked appropriately.
    • ~If applicable, added the breaking change issue label (and filled out the breaking change checklist)
  • Designer checklist~
    • Updated the Figma library counterpart

- moves padding to grid the cell wrapper instead of grid cell content to ensure the padding does not affect the line-clamp
@mgadewoll mgadewoll added the bug label May 28, 2024
@mgadewoll mgadewoll changed the title [DataGrid][BugFix]: Fix visible truncated text [DataGrid][BugFix]: Fix visible overflowing truncated text May 28, 2024
@mgadewoll mgadewoll marked this pull request as ready for review May 28, 2024 14:51
@mgadewoll mgadewoll requested a review from a team as a code owner May 28, 2024 14:51
@mgadewoll mgadewoll marked this pull request as draft May 29, 2024 13:30
/>
</div>
</RenderTruncatedCellContent>
<div className={innerContentClasses}>
Copy link
Contributor Author

@mgadewoll mgadewoll May 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I generally don't like adding additional wrappers but we need to separate the line-clamp from the padding to ensure that the truncated text is hidden.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think my hangup is... I just honestly don't feel like it's worth it 🙈 it feels like an outsized performance impact (extra DOM node per cell, which will scale enormously on datagrids) for what's purely a visual effect. I'm tempted to look into other approaches if possible (pseudo element that "covers" the text? some other overflow CSS workaround?)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found the world's hackiest CSS workaround using a transparent border! Let me know what you think? main...cee-chen:eui:datagrid/line-clamp-css-workaround

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I totally agree - adding a wrapper is a big performance impact on DataGrid. That's why I'm also not really happy with it.
I checked your hacky workaround and it seems to work great! 🪄 I'd vote for that one as it's definitely way more lightweight 🪶 🎉

Copy link
Contributor Author

@mgadewoll mgadewoll May 31, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One small downside I notice is that it does not currently update when changing the controls in the story (e.g. gridStyle.fontSize - it renders correctly on reload though.)

Copy link
Member

@cee-chen cee-chen May 31, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After poking at it, I think this is an issue in production datagrid because gridStyles.fontSize doesn't correctly update the expected row height on the production storybook either (which is the underlying issue).

I'm not totally sure this is worth chasing down right now as consumers typically don't change custom gridStyle.fontSize on the fly (vs users using the density toolbar control). Am I way off on that?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. I reverted the wrapper changes in favor of your suggested transparent border hack here in this commit.

  2. I agree that the gridStyle issue is not a storybook issue but the prop generally doesn't trigger a recalculation.

In general this should not be an issue, as production would likely never on the fly change the styles via gridStyle prop, but in Storybook it seems weird/broken as we showcase the prop object and IMHO it's not apparent it's expected to not update. 😐

I gave it a quick shot to ensure the cell height calculation is triggered on fontSize and cellPadding change here in this commit. WDYT? (We don't have to implement this here if you don't agree with it, it's a suggestion in case we can fix it this way rather easily 🙂)

Copy link
Member

@cee-chen cee-chen Jun 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😬 I would kinda strongly prefer not to in this PR - if we do want to resolve it, I'd prefer it be a separate issue + PR to make it easy to roll back standalone if necessary.

For context, I'm generally paranoid/conservative about anything involving EuiDataGrid due to its scale which results in outsized rerender/performance issues, and the cascading impact the component has on power users.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, that's fair. I'll revert the last commit and move it to a separate PR then 🙂

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reverted in this commit.

ℹ️ I added a separate issue for the gridStyles update.

@mgadewoll mgadewoll marked this pull request as ready for review May 29, 2024 15:59
@cee-chen cee-chen enabled auto-merge (squash) June 4, 2024 19:53
@cee-chen cee-chen disabled auto-merge June 4, 2024 19:53
@cee-chen cee-chen changed the title [DataGrid][BugFix]: Fix visible overflowing truncated text [EuiDataGrid][BugFix]: Fix visible overflowing truncated text Jun 4, 2024
@cee-chen cee-chen enabled auto-merge (squash) June 4, 2024 19:54
@kibanamachine
Copy link

Preview staging links for this PR:

@elasticmachine
Copy link
Collaborator

💚 Build Succeeded

History

Copy link
Member

@cee-chen cee-chen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Definitely not me forgetting to actually select approve 🤦 ✅

@cee-chen cee-chen merged commit bcd8f3d into elastic:main Jun 5, 2024
5 checks passed
cee-chen added a commit to elastic/kibana that referenced this pull request Jun 18, 2024
`v94.6.0` ⏩ `v95.0.0-backport.0`

_[Questions? Please see our Kibana upgrade
FAQ.](https://github.com/elastic/eui/blob/main/wiki/eui-team-processes/upgrading-kibana.md#faq-for-kibana-teams)_

---

##
[`v95.0.0-backport.0`](https://github.com/elastic/eui/releases/v95.0.0-backport.0)

**This is a backport release only intended for use by Kibana.**

- Updated `EuiSteps` to support a new `titleSize="xxs"` style, which
outputs the same title font size but smaller unnumbered step indicators
([#7813](elastic/eui#7813))
- Updated `EuiStepsHorizontal` to support a new `size="xs"` style, which
outputs smaller unnumbered step indicators
([#7813](elastic/eui#7813))
- Updated `EuiStepNumber` to support new `titleSize="none"` which omits
rendering step numbers, and will only render icons
([#7813](elastic/eui#7813))

## [`v95.0.0`](https://github.com/elastic/eui/releases/v95.0.0)

- Added `move` glyph to `EuiIcon`
([#7789](elastic/eui#7789))
- Updated `EuiBasicTable` and `EuiInMemoryTable`s with `selection` - the
header row checkbox will now render an indeterminate state if some (but
not all) rows are selected
([#7817](elastic/eui#7817))

**Bug fixes**

- Fixed an `EuiDataGrid` visual bug when using `lineCount` row heights
where the clamped text was still visible for some font sizes
([#7793](elastic/eui#7793))
- Fixed `EuiSearchBar`'s filter configs to always respect `autoClose:
false` ([#7806](elastic/eui#7806))

**Breaking changes**

- Removed deprecated `EUI_CHARTS_THEME_DARK`, `EUI_CHARTS_THEME_LIGHT`
and `EUI_SPARKLINE_THEME_PARTIAL` exports
([#7682](elastic/eui#7682))
- Removed deprecated `euiPalettePositive` and `euiPaletteNegative`. Use
`euiPaletteGreen` and `euiPaletteRed` instead
([#7808](elastic/eui#7808))
- Removed `type="inList"` from `EuiCheckbox`. Simply omit passing a
`label` prop to render this style of checkbox
([#7814](elastic/eui#7814))
- Removed the unused `compressed` prop from `EuiCheckbox` and
`EuiRadio`. This prop was not doing anything on individual components.
([#7818](elastic/eui#7818))

**CSS-in-JS conversions**

- Converted `EuiCheckboxGroup` to Emotion
([#7818](elastic/eui#7818))
- Converted `EuiRadioGroup` to Emotion
([#7818](elastic/eui#7818))

---------

Co-authored-by: Cee Chen <[email protected]>
Co-authored-by: Kibana Machine <[email protected]>
Co-authored-by: Cee Chen <[email protected]>
bhapas pushed a commit to bhapas/kibana that referenced this pull request Jun 18, 2024
`v94.6.0` ⏩ `v95.0.0-backport.0`

_[Questions? Please see our Kibana upgrade
FAQ.](https://github.com/elastic/eui/blob/main/wiki/eui-team-processes/upgrading-kibana.md#faq-for-kibana-teams)_

---

##
[`v95.0.0-backport.0`](https://github.com/elastic/eui/releases/v95.0.0-backport.0)

**This is a backport release only intended for use by Kibana.**

- Updated `EuiSteps` to support a new `titleSize="xxs"` style, which
outputs the same title font size but smaller unnumbered step indicators
([elastic#7813](elastic/eui#7813))
- Updated `EuiStepsHorizontal` to support a new `size="xs"` style, which
outputs smaller unnumbered step indicators
([elastic#7813](elastic/eui#7813))
- Updated `EuiStepNumber` to support new `titleSize="none"` which omits
rendering step numbers, and will only render icons
([elastic#7813](elastic/eui#7813))

## [`v95.0.0`](https://github.com/elastic/eui/releases/v95.0.0)

- Added `move` glyph to `EuiIcon`
([elastic#7789](elastic/eui#7789))
- Updated `EuiBasicTable` and `EuiInMemoryTable`s with `selection` - the
header row checkbox will now render an indeterminate state if some (but
not all) rows are selected
([elastic#7817](elastic/eui#7817))

**Bug fixes**

- Fixed an `EuiDataGrid` visual bug when using `lineCount` row heights
where the clamped text was still visible for some font sizes
([elastic#7793](elastic/eui#7793))
- Fixed `EuiSearchBar`'s filter configs to always respect `autoClose:
false` ([elastic#7806](elastic/eui#7806))

**Breaking changes**

- Removed deprecated `EUI_CHARTS_THEME_DARK`, `EUI_CHARTS_THEME_LIGHT`
and `EUI_SPARKLINE_THEME_PARTIAL` exports
([elastic#7682](elastic/eui#7682))
- Removed deprecated `euiPalettePositive` and `euiPaletteNegative`. Use
`euiPaletteGreen` and `euiPaletteRed` instead
([elastic#7808](elastic/eui#7808))
- Removed `type="inList"` from `EuiCheckbox`. Simply omit passing a
`label` prop to render this style of checkbox
([elastic#7814](elastic/eui#7814))
- Removed the unused `compressed` prop from `EuiCheckbox` and
`EuiRadio`. This prop was not doing anything on individual components.
([elastic#7818](elastic/eui#7818))

**CSS-in-JS conversions**

- Converted `EuiCheckboxGroup` to Emotion
([elastic#7818](elastic/eui#7818))
- Converted `EuiRadioGroup` to Emotion
([elastic#7818](elastic/eui#7818))

---------

Co-authored-by: Cee Chen <[email protected]>
Co-authored-by: Kibana Machine <[email protected]>
Co-authored-by: Cee Chen <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[EuiDataGrid] Cell text content visible below truncation when using fontSize: "s"
4 participants