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] Fix cell props not clearing state on column reorder #5068

Merged
merged 5 commits into from
Aug 24, 2021

Conversation

cee-chen
Copy link
Contributor

@cee-chen cee-chen commented Aug 23, 2021

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

before

After

after

Checklist

  • Check against all themes for compatibility in both light and dark modes
  • Checked in mobile
  • Checked in Chrome, Safari, Edge, and Firefox

- [ ] 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

  • A changelog entry exists and is marked appropriately

@cee-chen cee-chen force-pushed the datagrid-cellprops-reorder branch from f824861 to 69f815a Compare August 23, 2021 20:31
@cee-chen
Copy link
Contributor Author

cee-chen commented Aug 23, 2021

@chandlerprall @thompsongl - I'm not super clear on how jest/unit tests are currently being handled for EuiDataGrid. Currently I'm not seeing any .test.tsx files for child EuiDataGrid components, so I don't think there's anything for me to write in here unless you'd like me to start one?

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)

Comment on lines +254 to +258
componentDidUpdate(prevProps: EuiDataGridCellProps) {
if (this.props.columnId !== prevProps.columnId) {
this.setCellProps({});
}
}
Copy link
Contributor Author

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.

Copy link
Contributor

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.

@kibanamachine
Copy link

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', () => {
Copy link
Contributor Author

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.

Copy link
Contributor

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 👍

@kibanamachine
Copy link

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', () => {
Copy link
Contributor

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 👍

Comment on lines +254 to +258
componentDidUpdate(prevProps: EuiDataGridCellProps) {
if (this.props.columnId !== prevProps.columnId) {
this.setCellProps({});
}
}
Copy link
Contributor

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.

@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_5068/

@cee-chen
Copy link
Contributor Author

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!

@cee-chen cee-chen merged commit 6c48745 into elastic:master Aug 24, 2021
@cee-chen cee-chen deleted the datagrid-cellprops-reorder branch August 24, 2021 16:34
cee-chen added a commit to cee-chen/kibana that referenced this pull request Aug 25, 2021
cee-chen added a commit to cee-chen/kibana that referenced this pull request Aug 31, 2021
cee-chen pushed a commit to elastic/kibana that referenced this pull request Sep 1, 2021
* 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>
kibanamachine added a commit to kibanamachine/kibana that referenced this pull request Sep 1, 2021
* 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>
kibanamachine added a commit to elastic/kibana that referenced this pull request Sep 1, 2021
* 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants