-
Notifications
You must be signed in to change notification settings - Fork 842
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] Fix grids that set a defaultHeight
with lineCount
and rowHeights
overrides with lineCount
#5376
[EuiDataGrid] Fix grids that set a defaultHeight
with lineCount
and rowHeights
overrides with lineCount
#5376
Conversation
- Remove line overrides from auto example (causes confusion during testing, isn't necessary)
…cache instead of setting the minRowHeight - the lineCount overrides are causing incorrect minRowHeight calculations for other rows, so they need their own specific map, and the auto one is right there 🤷
Preview documentation changes for this PR: https://eui.elastic.co/pr_5376/ |
45d6824
to
e7c6ed1
Compare
Preview documentation changes for this PR: https://eui.elastic.co/pr_5376/ |
@@ -218,6 +218,9 @@ describe('EuiDataGridCell', () => { | |||
}); | |||
|
|||
callMethod(component); | |||
expect( | |||
mockRowHeightUtils.calculateHeightForLineCount | |||
).toHaveBeenCalledWith(expect.any(HTMLElement), 3, false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TIL expect.any
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes LGTM! Tested in the PR's preview docs.
Preview documentation changes for this PR: https://eui.elastic.co/pr_5376/ |
Summary
I found this bug while QAing my row height switcher work 🐛
Problem
The bug was caused by #5354: the switch to using
minRowHeight
state forlineCount
assumed that every single row in the grid would be the same height, and did not account for therowHeights
object which allows overriding specific rows with customlineCount
s, e.g.:The bug results in the before gif you can see below, where multiple rows are all fighting to set different
minRowHeight
s 😬 (EDIT: The gif actually doesn't have the FPS to capture the extent of the brokenness, there's way more flashing stuff going on if you test the REVERT commit against prod).Solution
The solution I came up with was to bogart the existing
heightsCache
that auto heights use, but for lineCount overrides only. This is probably a little over-engineered for lineCount heights, but since I doubt many consumers are setting customrowHeights.lineCounts
, I don't think it'll have a significant performance impact, and from a developer readability standpoint I think it's not adding too much spaghetti (and said spaghetti at least has comments + unit tests added for context).Before
before.mp4
After
after.mp4
Extra
This PR also simplifies the
auto
height example, as that example does not needrowHeights
overrides and it was always really confusing to me while debugging/testing 🙈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 appropriatelyLeaving out a changelog as this bug is in