[EuiDataGrid] Update display selector UI when gridStyle and rowHeightsOptions props change#5526
Merged
cee-chen merged 10 commits intoelastic:mainfrom Jan 12, 2022
Merged
[EuiDataGrid] Update display selector UI when gridStyle and rowHeightsOptions props change#5526cee-chen merged 10 commits intoelastic:mainfrom
gridStyle and rowHeightsOptions props change#5526cee-chen merged 10 commits intoelastic:mainfrom
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/ |
3 tasks
Contributor
chandlerprall
left a comment
There was a problem hiding this comment.
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/ |
chandlerprall
approved these changes
Jan 12, 2022
|
Preview documentation changes for this PR: https://eui.elastic.co/pr_5526/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Caveatheading)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
gridStylebutton and setfontSizeandcellPaddingboth to largeSet row height to autotest 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