-
Notifications
You must be signed in to change notification settings - Fork 842
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] Fix cell props not clearing state on column reorder #5068
Conversation
f824861
to
69f815a
Compare
@chandlerprall @thompsongl - I'm not super clear on how jest/unit tests are currently being handled for EuiDataGrid. Currently I'm not seeing any Alternatively, I can make a note/self-todo to write a Cypress test for this specifically once the current Cypress tests land - thoughts? EDIT: Unit test added, see #5068 (review) |
componentDidUpdate(prevProps: EuiDataGridCellProps) { | ||
if (this.props.columnId !== prevProps.columnId) { | ||
this.setCellProps({}); | ||
} | ||
} |
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.
Let me know if you have a preferred/cleaner approach of solving this issue! I'm not in love with this or anything, although it seemed like the most straightforward solution - but I could be definitely missing something or an edge case.
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.
This makes sense to me. @chandlerprall can chime in if he has other thoughts, though.
Preview documentation changes for this PR: https://eui.elastic.co/pr_5068/ |
@@ -1467,6 +1467,48 @@ describe('EuiDataGrid', () => { | |||
['1-ColumnB', '1-ColumnA'], | |||
]); | |||
}); | |||
|
|||
it('resets cell props on column reorder', () => { |
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.
@chandlerprall requested a unit test for this in Slack! This is mostly a direct copy/paste of the above column order test in terms of setup (but with 1 less row and setCellProps
in renderCellValue
). I'm not sure if there's any DRYing out I should be doing between the 2 reorder unit tests - happy to do so if requested.
I also ran this test on master and can confirm it fails there but passes on this branch.
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'm in favor of verbose testing 👍
Preview documentation changes for this PR: https://eui.elastic.co/pr_5068/ |
@@ -1467,6 +1467,48 @@ describe('EuiDataGrid', () => { | |||
['1-ColumnB', '1-ColumnA'], | |||
]); | |||
}); | |||
|
|||
it('resets cell props on column reorder', () => { |
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'm in favor of verbose testing 👍
componentDidUpdate(prevProps: EuiDataGridCellProps) { | ||
if (this.props.columnId !== prevProps.columnId) { | ||
this.setCellProps({}); | ||
} | ||
} |
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.
This makes sense to me. @chandlerprall can chime in if he has other thoughts, though.
Preview documentation changes for this PR: https://eui.elastic.co/pr_5068/ |
Going to go ahead and merge to get into the release today :) I'm happy to revert or open a follow-up PR if any changes are requested! |
This reverts commit e40ebfa.
* Upgrade EUI to v37.3.1 * Update i18n token mappings * Skip i18n_eui_mapping defString checks for functions * Update snapshots * Update failing Security tests with extra nodes * Remove hook cleanup now that elastic/eui#5068 is merged * [i18n PR feedback] Prefer specific token skipping over all functions skipping * Revert "Remove hook cleanup now that elastic/eui#5068 is merged" This reverts commit e40ebfa. Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
* Upgrade EUI to v37.3.1 * Update i18n token mappings * Skip i18n_eui_mapping defString checks for functions * Update snapshots * Update failing Security tests with extra nodes * Remove hook cleanup now that elastic/eui#5068 is merged * [i18n PR feedback] Prefer specific token skipping over all functions skipping * Revert "Remove hook cleanup now that elastic/eui#5068 is merged" This reverts commit e40ebfa. Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
* Upgrade EUI to v37.3.1 * Update i18n token mappings * Skip i18n_eui_mapping defString checks for functions * Update snapshots * Update failing Security tests with extra nodes * Remove hook cleanup now that elastic/eui#5068 is merged * [i18n PR feedback] Prefer specific token skipping over all functions skipping * Revert "Remove hook cleanup now that elastic/eui#5068 is merged" This reverts commit e40ebfa. Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> Co-authored-by: Constance <constancecchen@users.noreply.github.com>
Summary
closes #4599, and I believe should also close #4665
The before/after screenshots depict the issue quite clearly, so I'll let a picture speak a thousand words for me 😄
Before
After
Checklist
- [ ] Props have proper autodocs and playground toggles- [ ] Added documentation- [ ] Checked Code Sandbox works for the any docs examples- [ ] Checked for breaking changes and labeled appropriately- [ ] Checked for accessibility including keyboard-only and screenreader modes