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] Give rows actual positions/dimensions #5555

Merged
merged 14 commits into from
Feb 10, 2022

Conversation

cee-chen
Copy link
Member

@cee-chen cee-chen commented Jan 24, 2022

Summary

This PR handle gives our created row elements an actual presence in the grid DOM (position & width/height). This then allows us to significantly clean up our CSS to target the row DOM node instead of each cell within the row.

This PR does not fully address #4401, but gets us well on the way to doing so, as rows will now become actual targetable and stylable elements.

Checklist

  • Check against all themes for compatibility in both light and dark modes
  • Checked in mobile
  • Checked in Chrome, Safari, Edge, and Firefox

- [ ] Props have proper autodocs and playground toggles
- [ ] Added documentation
- [ ] Checked Code Sandbox works for any docs examples

- [ ] Checked for breaking changes and labeled appropriately

  • Checked for accessibility including keyboard-only and screenreader modes

- [ ] A changelog entry exists and is marked appropriately Internal only changes

@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_5555/

+ adjust scrolling workaround to obtain offsetTop from row parent instead of cell, now that individual cells have a top: 0
- now that cells are relative to the row parent, their offsetTop is 0
- Remove `@include euiDataGridRowCell` mixin and target the row directly

- Remove isStripableRow cell logic and instead use CSS nth-child for alternating stripes

- Swap stripes and highlight CSS so that highlight takes precendence over stripes without an !important

- Remove background color on individual cells to allow row colors to show through (NB: grid body is already set to the correct background color as well)
@cee-chen cee-chen force-pushed the datagrid/rows branch 2 times, most recently from 8ec0829 to 283e40b Compare February 7, 2022 22:17
@cee-chen cee-chen changed the title [EuiDataGrid] Give rows actual positions/dimensions and add a new gridStyle.rowClasses API for customizing row styles [EuiDataGrid] Give rows actual positions/dimensions Feb 7, 2022
@cee-chen cee-chen marked this pull request as ready for review February 7, 2022 22:19
@cee-chen
Copy link
Member Author

cee-chen commented Feb 7, 2022

I've removed the spiked rowClasses API from this PR and will open it as a separate draft PR for testing/discussion once this merges. I'd like to get this PR in separately as it allows us to significantly clean up some of our row-related CSS and styling.

@chandlerprall I'm not 100%, but I don't think this requires a changelog entry so it's primarily an internal only change to EuiDataGrid - am I off on that?

@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_5555/

- skipping the mutation observer for now
- cells no longer have a set background color (to allow row color to bleed through), and we were previously relying on the grid body's bg color to be white
@cee-chen
Copy link
Member Author

cee-chen commented Feb 7, 2022

Hmmm something funky is happening with the row height demos - the border for the horizontal scrollbar is showing up when it shouldn't be

https://eui.elastic.co/pr_5555/#/tabular-content/data-grid-row-heights-options

Not sure if this PR introduces or if it's already in main. Will test a bit more later

EDIT: It appears to be this PR and not in main. what the what

@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_5555/

@chandlerprall
Copy link
Contributor

@chandlerprall I'm not 100%, but I don't think this requires a changelog entry so it's primarily an internal only change to EuiDataGrid - am I off on that?

💯 internals-only modifications don't need a changelog

- using CSS `left`/`right` and `relative` on the inner grid parent solves the issue instead, as the row is now always correct width
@cee-chen
Copy link
Member Author

cee-chen commented Feb 9, 2022

Alrighty, the issue I screenshotted above should now be fixed with 006df04. The problem was that the containerRef in rowElement.style.width = containerRef.current!.style.width; was (for whatever bizarre reason) becoming stale particularly on out-of-view cells. Switching row elements to use pure CSS to obtain its width from the parent innerGrid element fixes the bug.

I also added data-gridrow-index attributes in a2397ee - I figured some consumers might find this helpful to hook into while we're still discussing the final API.

@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_5555/

- which does not work well due to children changing on virtualization

+ set additional visible row index data attribute for extra detail

+ use dataset
- was previously not working on prod, and now it does
@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_5555/

Copy link
Contributor

@chandlerprall chandlerprall left a comment

Choose a reason for hiding this comment

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

One small suggestion, feel free to ignore.

Tested locally & in the preview docs, couldn't find an issue. Included a specific check to ensure footer row striping still works as expected.

Don't forget to revert the striping example

src/components/datagrid/data_grid_types.ts Outdated Show resolved Hide resolved
Copy link
Contributor

@chandlerprall chandlerprall left a comment

Choose a reason for hiding this comment

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

Additional changes LGTM ❤️

@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_5555/

@cee-chen cee-chen enabled auto-merge (squash) February 10, 2022 17:35
@cee-chen cee-chen merged commit c1f5de4 into elastic:main Feb 10, 2022
@cee-chen cee-chen deleted the datagrid/rows branch February 10, 2022 17:52
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.

3 participants