Skip to content
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] Cells styling stick to cell's position when adding new columns #4665

Closed
dej611 opened this issue Mar 25, 2021 · 2 comments · Fixed by #5068
Closed

[EuiDataGrid] Cells styling stick to cell's position when adding new columns #4665

dej611 opened this issue Mar 25, 2021 · 2 comments · Fixed by #5068
Labels
data grid ⚠️ needs validation For bugs that need confirmation as to whether they're reproducible

Comments

@dej611
Copy link
Contributor

dej611 commented Mar 25, 2021

In Lens we're building a dynamic coloring feature for the datatable, which uses EuidataGrid underneath.
Only numeric cells can be coloured, so nor dates or string cells should have a background-color style set.

The code used to color cells in this demo is taken from the EuiDataGrid documentation:

Kapture.2021-03-25.at.17.48.28.mp4

Scrolling up and down makes cleans up the colouring on the second column rows.

To check if that was an issue I've forcefully styled the cell div without the useEffect and repeated the same scenario:

Kapture.2021-03-25.at.17.51.57.mp4

This time the second column rows won't get any styling.

I solved this issue on the consumer side by providing a return function to the useEffect that will clean it up:

useEffect(() => 
  ...whatever...
  return () =>
      setCellProps({
        style: {
          backgroundColor: undefined,
          color: undefined,
        },
      });
}, [...]);

Now new cells are properly cleaned up:

Kapture.2021-03-25.at.18.18.35.mp4
@chandlerprall chandlerprall added data grid ⚠️ needs validation For bugs that need confirmation as to whether they're reproducible labels Mar 25, 2021
@chandlerprall
Copy link
Contributor

This is likely a bug in the cell props management, looks like they aren't cleared from memory/cache when the cell's column and/or row identifiers change, requiring the reset performed on renderCellValue's unmount.

@cee-chen
Copy link
Contributor

cee-chen commented Aug 23, 2021

Heya @dej611! I think my PR #5068 which addresses #4599 should also address this. Any chance you can show me where your component is in Lens and maybe provide an example dataset so I can test and confirm this to be the case? I have this working on local Kibana!

lens

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
data grid ⚠️ needs validation For bugs that need confirmation as to whether they're reproducible
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants