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

Fixed bug in datagrid where Hide fields columns were cached #2725

Conversation

chandlerprall
Copy link
Contributor

@chandlerprall chandlerprall commented Jan 2, 2020

Summary

Fixes #2606

  • Fixed bug in EuiDataGrid where an updated column list was not reflected in the "Hide fields" popover
  • Added useResettingState custom hook, a pattern I've used a couple places and decided to formalize for this (open to better name suggestions)
  • Added regression unit test for bug in [Data Grid] "Hide fields" doesn't pick up changing columns #2606 and another to prevent a similar situation on the "Sort fields" popover

/cc @walterra

Checklist

- [ ] Check against all themes for compatability in both light and dark modes
- [ ] Checked in mobile
- [ ] Checked in IE11 and Firefox
- [ ] Props have proper autodocs
- [ ] Added documentation examples

  • Added or updated jest tests
  • Checked for breaking changes and labeled appropriately
    - [ ] Checked for accessibility including keyboard-only and screenreader modes
  • A changelog entry exists and is marked appropriately

@thompsongl
Copy link
Contributor

15:12:28     SyntaxError: /app/src/services/hooks/useResettingState.ts: Unexpected token (22:30)
15:12:28 
15:12:28       20 |   }, deps);
15:12:28       21 | 
15:12:28     > 22 |   return [state, setState] as const;
15:12:28          |                               ^
15:12:28       23 | }
15:12:28       24 | 

CI failure, but I get this locally also

@chandlerprall
Copy link
Contributor Author

chandlerprall commented Jan 2, 2020

Apparently our version of (jest|jest-babel|@babel/preset-typescript|something) doesn't support the as const syntax. I updated this PR to avoid that syntax, and will look at updating the test libraries next week (the syntax support is a blocker for #2717).

Copy link
Contributor

@thompsongl thompsongl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Confirmed it fixes the problem using the test case in the issue

@chandlerprall
Copy link
Contributor Author

jenkins test this

@chandlerprall
Copy link
Contributor Author

@thompsongl I renamed the hook to useDependentState and changed it's updateCount state to a hasMounted ref to avoid an unneeded re-render.

@chandlerprall chandlerprall merged commit 4bc4269 into elastic:master Jan 6, 2020
@chandlerprall chandlerprall deleted the bug/2606-datagrid-hide-fields-not-updating branch January 6, 2020 16:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Data Grid] "Hide fields" doesn't pick up changing columns
2 participants