-
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] Update display selector UI when gridStyle
and rowHeightsOptions
props change
#5526
Conversation
…ptions are passed by consumers - Previously useState() was caching initial styles/row heights so that developer prop changes (if not overridden by user settings) weren't reflected in the UI - This fix: - Adds `useEffect`s that fires whenever the merged consumer/user states change (so will automatically always set UI state based on most recent configurations) - Refactors out the need for the `intial*` vars - Refactors out the need for manual UI state setting within UI callbacks - Cleans up resetToInitialState callback to only have to set user configs back to empty objs
- now that we're no longer storing initial UI state - NB: this new `showResetButton` state is slightly less granular than the previous logic, because it doesn't check if the display state was changed back to the original initial state and only checks for a coarse 'did the user interact with the controls', but IMO this is an acceptable tradeoff and adds minimal friction in exchange for easier developer maintainability
- our merged configs are guaranteed to always be at least an empty object, so we can now remove some undefined checks
- unfortunately `shallow` in Enzyme does not invoke useEffect, so the lineCount UI no longer appears in the changed test. I modified the test to simply no longer have that call (as it was tangential to the main test case)
Preview documentation changes for this PR: https://eui.elastic.co/pr_5526/ |
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.
Left 2 thoughts, one wouldn't be actionable until some other PRs merge as well.
+ perf optimization - wrap grid setup in useMemo/useCallbacks to prevent extra unnecessary calls
Preview documentation changes for this PR: https://eui.elastic.co/pr_5526/ |
1 similar comment
Preview documentation changes for this PR: https://eui.elastic.co/pr_5526/ |
This reverts commit 196fe66.
Preview documentation changes for this PR: https://eui.elastic.co/pr_5526/ |
Preview documentation changes for this PR: https://eui.elastic.co/pr_5526/ |
Summary
Caveat
heading)Before
before.mp4
After
after.mp4
Caveat
Note that this fix only applies to prop changes that occur before the user interacts with the display selector. Once the user has chosen their own settings, those user settings will always override any passed props, regardless of whether the props update later. See the below example:
QA
gridStyle
button and setfontSize
andcellPadding
both to largeSet row height to auto
test buttonChecklist
- [ ] 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