-
Notifications
You must be signed in to change notification settings - Fork 841
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] Add rowHeightSwitcher logic + API change #5372
[EuiDataGrid] Add rowHeightSwitcher logic + API change #5372
Conversation
Preview documentation changes for this PR: https://eui.elastic.co/pr_5372/ |
89b2783
to
2057eaf
Compare
Preview documentation changes for this PR: https://eui.elastic.co/pr_5372/ |
0746aae
to
419ed6b
Compare
- so that both the columnSelector and displaySelector can use it
+ update docs: - reorder UI to match toolbar layout - fix legends + add unit tests (& improve some existing unit tests)
NYI: conditional lineCount controls + unit tests
+ fix cell height to dynamically on lineCount change
…efined heights but defined rowHeightsOptions objects e.g. - empty objs, or lineHeight set but nothing else + simplify this.props
…ined mode - Multiline content includes items with `<br>`/`<p>` tags etc that end up incorrectly vertically centered to their increased height
419ed6b
to
fd18b72
Compare
Preview documentation changes for this PR: https://eui.elastic.co/pr_5372/ |
… + density - by giving it the same setRowHeight logic as line counts with a single line + rename recalculateLineCountHeight for clarity now that it's no longer being used for just lineCount
fd18b72
to
39aa176
Compare
Preview documentation changes for this PR: https://eui.elastic.co/pr_5372/ |
@@ -139,7 +140,7 @@ | |||
.euiDataGridRowCell__expandFlex { | |||
position: relative; // for positioning expand button | |||
display: flex; | |||
align-items: center; | |||
align-items: baseline; |
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.
Without this fix (be59b08), cell contents that are multiline due to <br>
s/<p>
s/other non-text-wrapping means would not correctly be aligned on 'Single'/undefined row heights:
Before (center-aligned)
After (top/base-aligned)
Note that this actually already an issue on production, this PR simply makes it more obvious because the row height switcher easily allows users to switch to single/undefined row heights on multi-line content, whereas previously a consumer would likely set a static row height or lineCount
.
Also ignore the incorrect line height in this screenshot, this is an issue that gets fixed in the next commit.
const isSingleLine = rowHeightOption == null; // Undefined rowHeightsOptions default to a single line | ||
const lineCount = isSingleLine | ||
? 1 | ||
: rowHeightUtils?.getLineCount(rowHeightOption); |
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.
This fix/workaround essentially has the single/undefined row heights act as lineCount
of 1
, which allows single rows to take advantage of lineCount
's ability to get cell heights/font sizes/line heights and dynamically respond to density changes.
Before:
The non-dynamic height changing is even more noticeable now that single row heights are no longer center aligned (per previous commit/fix) and now that you can compare lineCount
directly against undefined
, which does correctly reset the minimum row height based on density.
After:
I initially played with an approach that used a static minRowHeight
map depending on density and exporting that from the display selector - but I think this approach is much simpler/better because it's using the logic we already have, and also accounts for row/line height differences between the legacy theme and Amsterdam theme.
This also fixes an issue that occurs when switching from lineCount
to undefined
heights - the undefined
heights' minRowHeight was not being correctly reset, so this approach basically kills two birds with one stone.
- to make the difference more obvious when switching between single and custom
Preview documentation changes for this PR: https://eui.elastic.co/pr_5372/ |
jenkins test this |
Preview documentation changes for this PR: https://eui.elastic.co/pr_5372/ |
…to datagrid-row-height-control
Preview documentation changes for this PR: https://eui.elastic.co/pr_5372/ |
Just to clarify, "Single" heights have never taken the actions column into account, what they did was just vertically center all of their content which was fine for things like buttons or text that never had manual I think the solution here is to tweak control columns buttons by reducing their size or padding/margins on compressed density (so it's not causing the height to be too tall on EDIT: Actually on second thought https://eui.elastic.co/pr_5372/#/tabular-content/data-grid-control-columns/ is fairly derpy as well (primarily checkboxes) even on normal density so I think the perhaps more robust solution is to switch control columns only back to a center vertical alignment (since theoretically those columns should not contain multi-line text). EDIT 2: Actually both is required. Fun times! |
This is tricky, and I flopped back and forth a bit in that section during my review. Looking ahead to the ask for row renderers, I can see a world where there are "rows" and ... "extra rows" (conceptually in the application, not within EUI code), with the extra rows getting an auto height while the rows use the default set by either application or user. Based on this, I lean toward the existing implementation where the override affects only the default. In theory, there's a really good reason for the application to set a specific height on something. I also appreciate the scenario where a user is confused when only a subset of rows are affected by their choice. |
Those are good points! Could we configure the specific rows example to turn off Is that a slightly happier medium between programmatically enforcing/disabling the row height switcher whenever a |
…to datagrid-row-height-control
So something like?: rowHeightsOptions = {
defaultHeight: 140, // Row heights selector still shows but unselected
rowHeights: {
1: {
lineCount: 5,
allowRowHeight: false, // Ensures it doesn't change based on row height selector
},
4: 200, // Will adjust based on row height selector, this is just the starting height
},
} |
Preview documentation changes for this PR: https://eui.elastic.co/pr_5372/ |
Not quite sorry, I just meant changing the actual <EuiDataGrid
// ...
toolbarVisibility={{
showDisplaySelector: { allowRowHeight: false },
}}
rowHeightsOptions={rowHeightsOptions} // has rowHeights overrides
/> |
Ok, as a compromise, add that to the docs example with a note in the description (and the props comment for |
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.
I'll apply my pre-approval now in case the rest of them come in while I'm out. 😅 Awesome job!! I think the final UI is intuitive and I'm glad we, but mostly you, took the time to work through all the rest of the toolbar stuff to go with it.
+ improve unit tests to cover undefined nested object key case
Preview documentation changes for this PR: https://eui.elastic.co/pr_5372/ |
…er when using `rowHeights` @see elastic#5411
Preview documentation changes for this PR: https://eui.elastic.co/pr_5372/ |
|
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.
LGTM! Read through & tested the updated examples, looks like all review feedback has been addressed.
Preview documentation changes for this PR: https://eui.elastic.co/pr_5372/ |
Interesting Cypress failure, gonna see if a re-run passes; jenkins test this
|
Preview documentation changes for this PR: https://eui.elastic.co/pr_5372/ |
It's failed a couple times now on this branch since latest main was merged in, so unfortunately I think it might be a persistent failure. I can repro it locally as well. An easy fix would just be to ignore the specific ResizeObserver loop limit error, but I'm a little worried it's somehow related to changes in this branch (although I can't really see how it would specifically affect E2E tests) |
HA, I've apparently run into this exact same ResizeObserver loop error in Enterprise Search: The security team also has a workaround for it: With that in mind + the responses from https://stackoverflow.com/questions/49384120/resizeobserver-loop-limit-exceeded I feel relatively safe pushing up a general |
Preview documentation changes for this PR: https://eui.elastic.co/pr_5372/ |
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.
🙌 thanks for tracking down all that info
ff742c6
into
elastic:feat/datagrid/toolbar-reorg-and-row-height-switcher
…5415) * [EuiDataGrid] Toolbar UI layout reorganization (#5334) * [EuiDataGrid] Add extra left prepend position to the `additionalControls` API (#5394) * [EuiDataGrid] Add rowHeightSwitcher logic + API change (#5372) * [EuiDataGrid] Add `onChange` callbacks for display selector changes (#5424) * [EuiDataGrid] Row height switcher should override `rowHeights` + add reset button (#5428) * [EuiDataGrid] improve height calculation (#5447) Co-authored-by: Caroline Horn <[email protected]> Co-authored-by: Chandler Prall <[email protected]>
Summary
This is a fairly hefty PR and I strongly recommend following along by commit.
TL;DR:
showStyleSelector
in favor ofshowDisplaySelector
showDisplaySelector
nested config options:{ allowDensity: true, allowRowHeight: true }
this.props.setRowHeight
to dynamically adjust theirminRowHeight
(basically re-using the same logic aslineCount
row heights)Screencaps
Code coverage
Checklist
- [ ] Checked Code Sandbox works for any docs examplesNOTE: Cypress testing will likely need #5371 for styles - leaving this as a tech debt/backlog item