-
Notifications
You must be signed in to change notification settings - Fork 840
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] Enhance renderCustomGridBody
to better support consumer virtualization
#8028
[EuiDataGrid] Enhance renderCustomGridBody
to better support consumer virtualization
#8028
Conversation
packages/eui/src/components/datagrid/body/cell/data_grid_cell.tsx
Outdated
Show resolved
Hide resolved
6b4fcdd
to
6e9474a
Compare
customGridBodyProps?.className | ||
)} | ||
> | ||
{headerRow} |
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.
FYI, the fact that we're no longer automatically rendering the header and footer row for custom grid bodies will need to constitute a breaking change. I'm not against it, but there are at least 2 current custom grid usages in Kibana that will need to be updated when this change is made, or production usage will break.
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.
yes I noted below occurences and I will be changing those as well in addition to couple of tests. So it should be okay.
Note
But I will need your help in how can I merge these EUI Changes for 8.16
and if it is possible or not.
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 should be able to get this into Kibana by 8.16 FF if I merge this in and do a release today. Does that work for you?
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.
Woohoo.. Thanks @cee-chen for merging it.
rowHeightUtils, | ||
}); | ||
|
||
const headerRowProps = useMemo(() => { |
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.
Just to check, were the props not correctly getting memoized by these lines? 😬
eui/packages/eui/src/components/datagrid/body/header/use_data_grid_header.tsx
Lines 23 to 25 in 4534175
const headerRow = useMemo(() => { | |
return <EuiDataGridHeaderRow ref={setHeaderRowRef} {...props} />; | |
}, [props]); |
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.
Yes, this was the strange one. Although props were exactly the same ( same identity ) but when passed into useDataGridHeader
as an object, identify to props
object recieved in useDataGridHeader
was changing. Possibly because I think it was creating a new object everytime to pass as props
.
This was causing headerRow
to be recreated and renderCustomBody
to be completely render again.
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.
Gotcha, thanks so much for explaining!
Hey Jatin, apologies for dropping the ball on this PR! I'll spend tomorrow pushing up some docs changes (probably merging the two examples so there's just one), and then update the changelog to highlight that this PR contains a breaking change. Other than that I think this is good to go. |
- which allows conditionally rendering the prop - errors otherwise + tweak displayName
- give this example its own folder, it's gotten complex enough at this point - also give it its own custom toggles and tabs, since codesandbox doesn't generate a link with relative imports
- these are all definitively passed
This PR contains breaking changes. The opener of this pull request is asked to perform the following due diligence steps below, to assist EUI in our next Kibana upgrade:
|
💚 Build Succeeded
History
cc @cee-chen |
renderCustomGridBody
to better support consumer virtualization
I was going to push up some Storybook VRT screenshots, but my local Docker is running into issues 🥲 to avoid holding up this PR further, I'm going to go ahead and merge it in and follow up with Storybook later. Thanks so much for this PR Jatin! |
Thanks @cee-chen for pushing it so quickly and creating a PR in Kibana. I do not see any DataGrid issues in your Kibana PR so please let me know if something pops up. Additionally, I see couple of minor issues with
Thanks. |
Nice catch on the docs! Unfortunately our CodeSandbox integration is pretty limited in how it allows importing multiple local files - hence the semi-broken behavior here. I believe we'll be switching to a different setup with live code in our new EUI+ docs, so this won't be an issue for much longer. My preference would be to leave it without a fully working CodeSandbox example for now as I think having discrete examples of custom grid bodies instead of 1 long and hard to read file is going to be easier for devs to follow along and copy into their setups, if needed. |
Makes sense. thanks @cee-chen |
`v96.1.0`⏩`v97.0.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)_ --- ## [`v97.0.0`](https://github.com/elastic/eui/releases/v97.0.0) **Breaking changes** - EuiDataGrid's custom grid body (rendered via `renderCustomGridBody`) no longer automatically renders the column header row or footer rows. It instead now passes the `headerRow` and `footerRow` React elements, which require manual rendering. ([#8028](elastic/eui#8028)) - This change was made to allow consumers to sync header/footer rows with their own custom virtualization libraries. - To facilitate this, a `gridWidth` prop is now also passed to custom grid body renderers. **Bug fixes** - Fixed inputs not taking the whole width when passing `fullWidth` as `true` to EuiDatePickerRange component ([#8061](elastic/eui#8061)) **Accessibility** - Improved accessibility of `EuiExternalLinkIcon` by clarifying text for Screen Reader users. ([#8065](elastic/eui#8065)) --------- Co-authored-by: Elastic Machine <[email protected]>
`v96.1.0`⏩`v97.0.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)_ --- ## [`v97.0.0`](https://github.com/elastic/eui/releases/v97.0.0) **Breaking changes** - EuiDataGrid's custom grid body (rendered via `renderCustomGridBody`) no longer automatically renders the column header row or footer rows. It instead now passes the `headerRow` and `footerRow` React elements, which require manual rendering. ([elastic#8028](elastic/eui#8028)) - This change was made to allow consumers to sync header/footer rows with their own custom virtualization libraries. - To facilitate this, a `gridWidth` prop is now also passed to custom grid body renderers. **Bug fixes** - Fixed inputs not taking the whole width when passing `fullWidth` as `true` to EuiDatePickerRange component ([elastic#8061](elastic/eui#8061)) **Accessibility** - Improved accessibility of `EuiExternalLinkIcon` by clarifying text for Screen Reader users. ([elastic#8065](elastic/eui#8065)) --------- Co-authored-by: Elastic Machine <[email protected]> (cherry picked from commit cd60c66)
Summary
See #8002
This PR tries to provide more control to the users of DataGrid when they pass
renderCustomGridBody
prop. Below are the changes done.Changes
headerRow
andfooterRow
are now passed torenderCustomBody
component for the user of data grid to render. This was done so that if users are rendering rows in a custom manner, those customization can also be applied to header and footer rows. For example, I was trying to use a virtualized table component where there was option to scroll the table horizontally, sinceheaderRow
was already rendered by EUI, I did not have option to contain it within a section same as table and hence scrolling was different in headerRow and the actual table.More memoizations in
packages/eui/src/components/datagrid/body/data_grid_body_custom.tsx
hereExisting Issues
Below issues exist in custom body render and currently, I do not have a good way to resolve these but these are also low priority.
customRenderBody
. CurrentlycustomRenderBody
function does not have any way to recalculate the width of data grid. ( DataGrid width is more than a container with customBodyRender #8038)maxWidth
to the cell content in order to restrict that to the width of the header.QA
Below is the demo on how virtualization with
Event Renderer
looks like.render_custom_body_eui_PR_demo.mp4
General checklist
@default
if default values are missing) and playground toggles[ ] Checked Code Sandbox works for any docs examples