-
Notifications
You must be signed in to change notification settings - Fork 843
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[EuiDataGrid] Refactor row height calculations to no longer need comp…
…uted styles on grid init (#5284) * Initial attempt using static maps NB: Saving this commit for historical purposes; but the issue with this solution is that lineHeight & fontSize change between legacy and Amsterdam theme and thus the calculations are wrong on the legacy theme - Switch to static padding/fontSize/lineHeights maps instead of classes - Undefined line height will NaN without euiDataGridRow CSS - Remove this.fakeCell class instance since it's only used in one place * Misc rowHeightUtils fixes/refactors - Export single default/initial row height const which data_grid_body imports, instead of declaring 2 slightly different heights in 2 different locations - fix rowIndex check that would fail on a rowIndex of 0 * Refactor isDefinedHeight and several rowHeightsOptions logic checks into a getRowHeightOption helper - this helper DRYs out returning either a specific row's height config or the defaultHeight - we had this logic essentially repeated in multiple places * Clean up shared cell props - Pull out shared/same props into a single obj instead of repeating it 3x & making it less clear which props are different depending on the cell type - remove getRowHeight fn from being passed down; it's not being used - pass setRowHeight only to first column as a performance optimization; this will be used for lineCount heights and since lineCount heights are all the same, we really only need to run it once - clean up footer row cells as well while we're here * Convert lineCount rows to use this.props.setRowHeight state from data_grid_body - IIRC this is what the state was originally used for; might as well go back to using it for lineCount * Update computeStylesForGridCell to remove fontSize & lineHeight calcs - Those were only being used for lineCount calculations; otherwise only padding is needed + remove numberFromPx in favor of a map with existing numbers * Rename computeStylesForGridCell now that it's no longer computing styles & remove getComputedCellStyles - re: getComputedCellStyles - I'm not seeing this affect either numeric, lineCount, or auto heights when changing grid density, hence me removing this * Remove unused CSS classes Now that we aren't using this CSS for computed styles any longer, we can remove them * Remove now-unused cell wrapper observer - we're exclusively watching the cell content now for both auto and line count heights * Rename recalculateRowHeight to recalculateAutoHeight - to make it more specific and clearer from the fn name what row height behavior this belongs to * Unit tests + mock improvements - add unit tests for recalculateLineCountHeight, - mockRowHeightUtils - allow some generic methods to return their actual fns for expedience - Remove jest.mock from data_grid.test.tsx - the __mocks__ folder automatically mocks it - update snapshots/returns accordingly * Add changelog entry * Fix crashing eui.d.ts * Fix changelog after release
- Loading branch information
Constance
authored
Nov 3, 2021
1 parent
d797498
commit 95e15fa
Showing
11 changed files
with
202 additions
and
276 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.