-
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
[Datagrid] Fix rowHeightOption: auto datagrid calculation issue #8251
Conversation
If anyone is interested https://github.com/kqualters-elastic/eui/tree/row-height-debug has console.logs in the places where you can see the calculation fail, adding a height of 0 to the unconstrained height state, and then (incorrectly) incrementing the knownRowCount. For reproducing, happened immediately on my OSX laptop, on Windows desktop, I had to mess with the zoom level of the browser + the size of the window in order to trigger the bug. |
The failing test is https://github.com/elastic/eui/blob/main/packages/eui/src/components/datagrid/data_grid.spec.tsx#L66 and is probably a bad test IMO. The test is not measuring the unconstrained height from the useUnconstrainedHeight hook, but finalHeight from useFinalGridDimensions. That hook has a height state that would have to be destroyed, or set to 0 at some point, so that this ternary uses unconstrainedHeight
and I think the only reason it passes is because in one of the calculation loops, all heights are 0, similar to the bug in a way. |
I can confirm this fixes the original bug where the data grid collapses to 0 (#8245) I also found a hardcoded
@kqualters-elastic thanks a lot for opening this and sharing your thoughts! Regarding the test mentioned above, I still need to run it and understand it 🙏 …but I'm guessing here (with the bug fixed) it's failing, and it was passing before but actually asserting the wrong behaviour, correct? — what would you do about it in relation to this PR? |
Locally for me |
Locally both are passing for me 😂 |
for me as well now haha, the one with the horizontal scrollbar needs a particular system setting while running locally! This 1-liner fix looks good for me! I would only create a new issue to investigate/address:
Let's wait for the team 🙂 |
after seeing how cypress fails for React 16 and 17, I think this needs another look. I can confirm the mainOn
![]() this branchOn this branch, it passes for React 18 only, and the height is not the expected:
![]() I guess we need to figure out whether the test needs some adjustment or the fix is not good enough? |
I'm working on getting these tests fixed, and if there are no other blockers, we should be able to get it merged this week |
Hey @tkajtoch , Let us know if you need any assistance from our side in getting these tests fixed. |
The only way to prevent bugs in the SIEM is if someone opens the alerts page in all supported web-browsers before doing a new release. This was someone all customers were raising at the engineering all hands in Prague last year. |
Thanks @mbudge for your revert. We can do the testing but wanted to confirm if anymore changes are required. One problem with this kind of bug is it is not 100% reproducible so that always leaves room for error. But Security solution will be happy to test it. |
We have at least 3 different users working in 3 different work environments on 2 browsers affected. Pretty sure someone manually checking the page is working before allowing a new release would mitigate the risk. Automated testing is good but has it's limitations. |
To speed things up, I'm going to comment out the flaky tests in this PR and address them separately. It seems that the fix works flawlessly for real users |
Preview staging links for this PR:
|
💚 Build Succeeded
History
cc @tkajtoch |
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.
Tested locally in EUI and Kibana on main
and eui-theme/borealis
. Everything works as expected. LGTM
…tic#8251) Co-authored-by: Tomasz Kajtoch <[email protected]> Co-authored-by: Tomasz Kajtoch <[email protected]>
Event rendered view is still broken in chrome in 8.16.4. |
`99.1.0-borealis.0` ⏩ `99.2.0-borealis.0` [Questions? Please see our Kibana upgrade FAQ.](https://github.com/elastic/eui/blob/main/wiki/eui-team-processes/upgrading-kibana.md#faq-for-kibana-teams) --- ## [`v99.2.0`](https://github.com/elastic/eui/releases/v99.2.0) - Changed `EuiFieldText` styles to prioritize `disabled` styling over `readonly`. ([#8271](elastic/eui#8271)) - Added `plugs` and `web` glyphs to `EuiIcon` ([#8285](elastic/eui#8285)) - Update `title` on `EuiColorPalettePickerPaletteProps` to be optional ([#8289](elastic/eui#8289)) **Bug fixes** - Fixed an issue with EuiDataGrid with auto row height resulting in a table of 0 height ([#8251](elastic/eui#8251)) - Fixed `disabled` behavior of `EuiFieldText` to prevent input changes. ([#8271](elastic/eui#8271)) **Borealis changes** - [Visual Refresh] Provide hooks for color palette functions ([#8284](elastic/eui#8284)) - [Visual Refresh] Make Borealis default theme in EUI ([#8288](elastic/eui#8288)) --- As you can probably tell, there are plenty of updated tests and snapshots this time around. They are the result of the following: 1. We've updated the default theme in `@elastic/eui` v99.2.0 to Borealis, which led to kibana tests using `renderWithTheme`, `mountWithTheme`, and other utility functions that wrap the tested component in `<EuiThemeProvider>` to switch to the correct, new color values. With this change, all tests should now use Borealis, regardless of the testing framework or its configuration. 2. Because of the default theme change in EUI, some class name hash fragments (e.g., `css-`**`wprskz`**`-euiButtonIcon-xs-empty-primary`) regenerated. Most Borealis-related changes in this PR are test env only and have no impact on what users see when using Kibana. --------- Co-authored-by: Elastic Machine <[email protected]>
`99.1.0-borealis.0` ⏩ `99.2.0-borealis.0` [Questions? Please see our Kibana upgrade FAQ.](https://github.com/elastic/eui/blob/main/wiki/eui-team-processes/upgrading-kibana.md#faq-for-kibana-teams) --- ## [`v99.2.0`](https://github.com/elastic/eui/releases/v99.2.0) - Changed `EuiFieldText` styles to prioritize `disabled` styling over `readonly`. ([elastic#8271](elastic/eui#8271)) - Added `plugs` and `web` glyphs to `EuiIcon` ([elastic#8285](elastic/eui#8285)) - Update `title` on `EuiColorPalettePickerPaletteProps` to be optional ([elastic#8289](elastic/eui#8289)) **Bug fixes** - Fixed an issue with EuiDataGrid with auto row height resulting in a table of 0 height ([elastic#8251](elastic/eui#8251)) - Fixed `disabled` behavior of `EuiFieldText` to prevent input changes. ([elastic#8271](elastic/eui#8271)) **Borealis changes** - [Visual Refresh] Provide hooks for color palette functions ([elastic#8284](elastic/eui#8284)) - [Visual Refresh] Make Borealis default theme in EUI ([elastic#8288](elastic/eui#8288)) --- As you can probably tell, there are plenty of updated tests and snapshots this time around. They are the result of the following: 1. We've updated the default theme in `@elastic/eui` v99.2.0 to Borealis, which led to kibana tests using `renderWithTheme`, `mountWithTheme`, and other utility functions that wrap the tested component in `<EuiThemeProvider>` to switch to the correct, new color values. With this change, all tests should now use Borealis, regardless of the testing framework or its configuration. 2. Because of the default theme change in EUI, some class name hash fragments (e.g., `css-`**`wprskz`**`-euiButtonIcon-xs-empty-primary`) regenerated. Most Borealis-related changes in this PR are test env only and have no impact on what users see when using Kibana. --------- Co-authored-by: Elastic Machine <[email protected]> ## Summary Summarize your PR. If it involves visual changes include a screenshot or gif. ### Checklist Check the PR satisfies following conditions. Reviewers should verify this PR satisfies this list as well. - [ ] Any text added follows [EUI's writing guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses sentence case text and includes [i18n support](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md) - [ ] [Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html) was added for features that require explanation or tutorials - [ ] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios - [ ] If a plugin configuration key changed, check if it needs to be allowlisted in the cloud and added to the [docker list](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker) - [ ] This was checked for breaking HTTP API changes, and any breaking changes have been approved by the breaking-change committee. The `release_note:breaking` label should be applied in these situations. - [ ] [Flaky Test Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was used on any tests changed - [ ] The PR description includes the appropriate Release Notes section, and the correct `release_note:*` label is applied per the [guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process) ### Identify risks Does this PR introduce any risks? For example, consider risks like hard to test bugs, performance regression, potential of data loss. Describe the risk, its severity, and mitigation for each identified risk. Invite stakeholders and evaluate how to proceed before merging. - [ ] [See some risk examples](https://github.com/elastic/kibana/blob/main/RISK_MATRIX.mdx) - [ ] ...
@mbudge I would appreciate more information like the testing path, a video 🙏🏻 I'm following what's said in the issue: #8245 I checked out Screen.Recording.2025-02-13.at.18.04.15.movI even checked the EUI version that 8.16 uses - Screen.Recording.2025-02-13.at.17.21.16.movSo this must've been an issue introduced later in the DataGrid. |
@weronikaolejniczak the fun part about this and all related bugs, is that it only happens in some circumstances for some users, as the browser introduces floating point rounding related errors in some situations, that then make their way into the datagrid's code paths when we use getBoundingClientRect and the like. This bug I never ran into on osx using defaults, but saw right away on windows. Was able to reproduce on osx eventually by changing my browser zoom level to 90%/110%, and/or filtering the table down to 1 entry, and switching the row height type. If neither of those work feel free to slack me and I can help, there are a few more ways I know of that can possibly cause this. |
Refresh the page and select event rendered view without clicking around. The density option is not set by default. Apparently the fix is being backported to 8.16.5 |
`99.1.0-borealis.0` ⏩ `99.2.0-borealis.0` [Questions? Please see our Kibana upgrade FAQ.](https://github.com/elastic/eui/blob/main/wiki/eui-team-processes/upgrading-kibana.md#faq-for-kibana-teams) --- ## [`v99.2.0`](https://github.com/elastic/eui/releases/v99.2.0) - Changed `EuiFieldText` styles to prioritize `disabled` styling over `readonly`. ([elastic#8271](elastic/eui#8271)) - Added `plugs` and `web` glyphs to `EuiIcon` ([elastic#8285](elastic/eui#8285)) - Update `title` on `EuiColorPalettePickerPaletteProps` to be optional ([elastic#8289](elastic/eui#8289)) **Bug fixes** - Fixed an issue with EuiDataGrid with auto row height resulting in a table of 0 height ([elastic#8251](elastic/eui#8251)) - Fixed `disabled` behavior of `EuiFieldText` to prevent input changes. ([elastic#8271](elastic/eui#8271)) **Borealis changes** - [Visual Refresh] Provide hooks for color palette functions ([elastic#8284](elastic/eui#8284)) - [Visual Refresh] Make Borealis default theme in EUI ([elastic#8288](elastic/eui#8288)) --- As you can probably tell, there are plenty of updated tests and snapshots this time around. They are the result of the following: 1. We've updated the default theme in `@elastic/eui` v99.2.0 to Borealis, which led to kibana tests using `renderWithTheme`, `mountWithTheme`, and other utility functions that wrap the tested component in `<EuiThemeProvider>` to switch to the correct, new color values. With this change, all tests should now use Borealis, regardless of the testing framework or its configuration. 2. Because of the default theme change in EUI, some class name hash fragments (e.g., `css-`**`wprskz`**`-euiButtonIcon-xs-empty-primary`) regenerated. Most Borealis-related changes in this PR are test env only and have no impact on what users see when using Kibana. --------- Co-authored-by: Elastic Machine <[email protected]> (cherry picked from commit e5958a4) # Conflicts: # src/platform/packages/shared/kbn-unified-data-table/src/components/compare_documents/hooks/__snapshots__/use_comparison_css.test.ts.snap # x-pack/solutions/security/packages/kbn-securitysolution-exception-list-components/src/exception_item_card/conditions/entry_content/__snapshots__/entry_content.test.tsx.snap # x-pack/solutions/security/plugins/security_solution/public/explore/network/components/embeddables/__mocks__/mock.ts
Co-authored-by: Tomasz Kajtoch <[email protected]> Co-authored-by: Tomasz Kajtoch <[email protected]>
Summary
Resolves #8245
The useUnconstrainedHeight hook used by datagrid has I think a subtle bug in it around auto height rows, in cases where the row height is 'auto' for all the rows in the table, and when datagrid is aware of them early in the multiple renders it uses to settle on a height, the returned value of this hook, an integer representing the height of the datagrid if it were rendered completely in full is returned as a number based on just the header row height, as described in the issue above. The reason for this, I believe, is because RowHeightUtils.getRowHeightOption will return not always a number, but sometimes the string 'auto' as well. That causes the if at https://github.com/elastic/eui/blob/main/packages/eui/src/components/datagrid/utils/grid_height_width.ts#L137 to be true, and as this is the first time we are attempting to determine the height of this row, the heightsCache of the RowHeightUtils class (these really desperately need to be converted to hooks, and a lot of these problems will disappear) returns 0 for all rows when calling getRowHeight, but we increment the knownRowCount anyway, and the result is this bug. The fix in this PR seems to be the most minimal way to fix this, however I think refactoring the class based utils that revolve around EuiDataGridRowHeightOption/EuiDataGridRowHeightsOptions would be best long term, as now multiple unneeded re-renders are forced from callbacks to force checks like useUnconstrainedHeight to be correct, which is bad for performance, but also calculations that happen outside of the React lifecycle, like with the RowHeightUtils class, unexpectedly do not happen at all in some cases, leading to bugs like this. A well done custom hooks approach could solve both problems at once. I have a branch somewhere with EuiDataGridCell converted from a class based component to a functional one to enable this I think.
QA
Remove or strikethrough items that do not apply to your PR.
General checklist
@default
if default values are missing) and playground toggles