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] Update to use EuiTextBreakTruncate + cell DOM & CSS cleanup #7255

Merged
merged 16 commits into from
Oct 9, 2023

Conversation

cee-chen
Copy link
Contributor

@cee-chen cee-chen commented Oct 4, 2023

Summary

This PR started as just updating EuiDataGrid to use the new EuiTextBreakTruncate component... and then I kept staring at the code going "ugh this is so hard to read/understand" and then several hours later I'd done my favorite thing, which is cleaning up code (and discovering a bug or two along the way) 🤣

I split up the commits by emoji to signify which items were refactors (🔥). I also recommend reading the commit messages as I tried to explain my reasoning for certain changes as I went along.

This is a refactor PR and no functionality or end-user experience should have degraded as a result of this PR. If that is not the case / if you find a regression, please let me know!

QA

Regression testing:

  • Go to https://eui.elastic.co/pr_7255/#/tabular-content/data-grid
  • Confirm that by default, only a single line of text renders with overflowing text being correctly truncated
  • Click the Display options button icon in the top right hand corner, and set the Row height control to Auto fit
  • Confirm each cell has visible and non-truncated content, and each cell is the same height as the tallest cell
  • Change the grid row height to Custom (should default to 2 lines per row)
  • Confirm long text correctly truncates after 2 lines, and the euiTextBreakTruncate className is present
  • Open the display options again and change the line count to 4. Confirm behavior continues to work
  • Repeat the above steps on production and confirm that all behaviors are the same as on saging

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, refactor only
  • Code quality checklist
  • Release checklist - N/A, refactor that should not have affected either end-users or consumers
  • Designer checklist - N/A

@cee-chen cee-chen changed the title [EuiDataGrid] Update to dogfood new EuiTextBreakTruncate component [EuiDataGrid] Update to use new EuiTextBreakTruncate component Oct 4, 2023
- in favor of a more agnostic height-type util

- We'll be replacing the line count styles with the new `EuiTextBlockTruncate` component

- NOTE: the `height: 100%` style needs to be retained for `lineCount` and `numerical` height types, hence the new util that will be passed to a CSS class
- Remove unnecessary `flex-grow: 1` - isn't doing anything

+ start the process of moving out the text truncation/breaking CSS to their className utils
- allows us to remove torturous selector and repeat CSS in favor of using explicit className utils

- `isDefinedHeight` is no longer used, remove it
@cee-chen cee-chen changed the title [EuiDataGrid] Update to use new EuiTextBreakTruncate component [EuiDataGrid] Update to use new EuiTextBreakTruncate component + cell DOM & CSS cleanup Oct 4, 2023
@cee-chen cee-chen force-pushed the text-truncation-multi-2 branch 2 times, most recently from 1e300f5 to 4c4dc57 Compare October 4, 2023 23:30
@cee-chen cee-chen changed the title [EuiDataGrid] Update to use new EuiTextBreakTruncate component + cell DOM & CSS cleanup [EuiDataGrid] Update to use EuiTextBreakTruncate + cell DOM & CSS cleanup Oct 4, 2023
- `overflow` is already set by text truncate component

- `height: 100%` doesn't appear to do anything or be useful. if for some reason it is needed in the future, we can always re-add it
- in favor of passing condition/setting conditional styling logic directly in the cell actions component
- pass var(s) instead of re-getting it twice
- move all logic related to content to the `EuiDataGridCellContent` component, including the wrapper

let the parent cell pass down any needed refs + actions
- remove extremely confusing `__expand` class names in favor of using the height type (that determines the kind of behavior the content has, e.g. flex vs absolutely positioned, etc)

- Make sure only the heights that need certain CSS have that CSS (the non-default-height cells don't need display flex)
- move flex CSS specific to default height cells to its selector, vs. the baseline actions component
…ts that have overflowing content

+ Add Cypress regression tests to ensure popovers are rendering from the correct anchor/position
@cee-chen cee-chen force-pushed the text-truncation-multi-2 branch from 4c4dc57 to c5343af Compare October 4, 2023 23:53
@cee-chen cee-chen marked this pull request as ready for review October 4, 2023 23:59
@cee-chen cee-chen requested a review from a team as a code owner October 4, 2023 23:59
@cee-chen cee-chen requested a review from 1Copenut October 5, 2023 00:01
@cee-chen
Copy link
Contributor Author

cee-chen commented Oct 5, 2023

@1Copenut I'd recommend focusing on the QA for this PR and only lightly skimming or skipping the code review 😅 Primarily what I want to be sure of is that cell display (when toggling to different height options) is the same as production, and that cell popover anchoring/positioning is also the same as production without regressions.

EDIT: Also no rush on reviewing this, I'm shooting to merge it in after next week's release to reduce churn (since we already have a few spicier changes going in this week, I want to spread this one out)

@kibanamachine
Copy link

Preview staging links for this PR:

@elasticmachine
Copy link
Collaborator

💚 Build Succeeded

History

Copy link
Contributor

@1Copenut 1Copenut left a comment

Choose a reason for hiding this comment

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

👍 I reviewed code briefly as you suggested @cee-chen and focused most of my efforts on manual QA. I ran through each of the suggested steps in the four evergreen browsers and confirmed the correct readout behavior in VoiceOver, NVDA, and JAWS with preferred browser pairings. Solid PR!

@cee-chen cee-chen merged commit cff6f41 into elastic:main Oct 9, 2023
1 check passed
@cee-chen cee-chen deleted the text-truncation-multi-2 branch October 9, 2023 22:59
cee-chen added a commit to cee-chen/kibana that referenced this pull request Oct 17, 2023
cee-chen added a commit to elastic/kibana that referenced this pull request Oct 19, 2023
`v89.0.0`⏩`v89.1.0`

This upgrade also contains an EuiDataGrid refactor
(elastic/eui#7255) not listed in the changelog
(as no end-user functionality or props changed as a result of the
refactor). The unlisted changes should only affect DOM and `className`
usages in Kibana (primarily CSS overrides and test selectors).

---

## [`89.1.0`](https://github.com/elastic/eui/tree/v89.1.0)

- Added `tokenVectorSparse` token and updated `tokenDenseVector` token
(now named `tokenVectorDense`).
([#7282](elastic/eui#7282))

**CSS-in-JS conversions**

- Reduced default CSS prefixes generated by Emotion to only browsers
supported by EUI (latest evergreen browsers). This can be customized by
passing your own Emotion cache to `EuiProvider`.
([#7272](elastic/eui#7272))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants