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] Cell style sticks to position when sorting #5583

Closed
PhaedrusTheGreek opened this issue Jan 31, 2022 · 1 comment · Fixed by #5665
Closed

[EuiDataGrid] Cell style sticks to position when sorting #5583

PhaedrusTheGreek opened this issue Jan 31, 2022 · 1 comment · Fixed by #5665
Labels
data grid ⚠️ needs validation For bugs that need confirmation as to whether they're reproducible

Comments

@PhaedrusTheGreek
Copy link
Contributor

EUI: 43.0.0

If I set a cell's style, then sort the grid, the style sticks to the old location. To workaround, I have to manually reset the background of the cell to white when it should not be coloured.

To reproduce, take the basic example here: Take the Grid example , and add a conditional:

numeric > 800 && setCellProps({
  style: {
    backgroundColor: `rgba(0, 255, 0, ${numeric * 0.0002})`,
  },
});

Then sort the table high to low, then low to high and the cells will still be coloured:

Screen Shot 2022-01-31 at 5 29 08 PM

@chandlerprall
Copy link
Contributor

chandlerprall commented Feb 1, 2022

Thanks for opening this issue to let us know!

This is caused by the cell component instance being reused when the logical cells are reordered. The call to setCellProps isn't expected to be conditional, so cases like this we've (specifically me, I think, if we need someone to blame) expected to be handled by returning an unmount handler from the useEffect to reset. For example, Kibana's Lens implemented this in cell_value.tsx lines 61-72, and an update to fix eui's datagrid.js example is to add return () => setCellProps({ style: {} }); at the end of the useEffect.

There was a similar issue before when reordering columns, which we considered a bug and committed a fix for.

I agree that this behaviour is not expected, and we should look at correcting that - my main concern is performance if we end up unmounting/recreating cells just to reset this value, but there's likely a better component lifecycle to target. We are exploring changing this API entirely (discussion #5566 if you want to add your thoughts!), which would need to account for this situation too.

@chandlerprall chandlerprall changed the title [DataGrid] Cell style sticks to position when sorting [EuiDataGrid] Cell style sticks to position when sorting Feb 1, 2022
@chandlerprall chandlerprall added data grid ⚠️ needs validation For bugs that need confirmation as to whether they're reproducible labels Feb 1, 2022
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.

2 participants