-
Notifications
You must be signed in to change notification settings - Fork 840
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
[EuiResizableContainer] Fix issue where onResizeEnd
becomes stale when renders occur between resize start and end
#7468
[EuiResizableContainer] Fix issue where onResizeEnd
becomes stale when renders occur between resize start and end
#7468
Conversation
…n renders occur between resize start and end
src-docs/src/views/resizable_container/resizable_container_callbacks.tsx
Outdated
Show resolved
Hide resolved
@@ -134,10 +138,10 @@ export const EuiResizableContainer: FunctionComponent< | |||
keyMoveDirection?: KeyMoveDirection; | |||
}>({}); | |||
|
|||
const resizeEnd = useCallback(() => { | |||
const resizeEnd = useStableCallback(() => { |
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.
For testing, swap this back to useCallback
and the resize callbacks example in the docs should fail to reset on resize end.
Heya Davis! I was going to take over this PR and apply the change to all EUI function components that add/remove window events, if that's cool, and also use EUI's existing |
@cee-chen That's great to hear, thanks for looking into it! And by all means, the PR is all yours 🙂 |
…tale when renders occur between resize start and end" This reverts commit 60c32b7.
- should fail in current prod
So it turns out this is actually the only component with this problem - all other components either are class components, where it's not an issue, or they use TBH, we should potentially consider switching this component to @davismcphee let me know if the switch to |
Preview staging links for this PR:
|
💚 Build Succeeded
History
|
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.
So it turns out this is actually the only component with this problem
Even better!
Pulled and tested locally, and confirmed the changes resolve the issue and the test catches the issue as expected. And I'm definitely in favour of using useLatest
over a bespoke utility for this. I'd give my approval, but I can't since I opened the PR originally 😁 That said, the changes LGTM and I'm looking forward to removing our workaround in Kibana after the next EUI upgrade 👍 Thanks!
Fantastic, thanks a million!! |
`v92.1.1`⏩`v92.2.1` --- ## [`v92.2.1`](https://github.com/elastic/eui/releases/v92.2.1) **Bug fixes** - Removed unintentional i18n tokens in prior release that should not have been exported ## [`v92.2.0`](https://github.com/elastic/eui/releases/v92.2.0) - Updated `EuiFlyoutResizable` with new optional `onResize` callback ([#7464](elastic/eui#7464)) **Bug fixes** - Fixed an issue in `EuiResizableContainer` where `onResizeEnd` could become a stale closure when renders occured between resize start and end, resulting in an outdated version of a consumer's `onResizeEnd` callback being called ([#7468](elastic/eui#7468)) - Fixed `EuiTextArea` to correctly fire `onChange` callbacks on clear button click ([#7473](elastic/eui#7473)) - Fixed `EuiContextMenu`'s panel titles & items to not show underlines on hover for non-interactive elements ([#7474](elastic/eui#7474)) **Deprecations** - Remove unused public `EuiHue` and `EuiSaturation` subcomponent exports. Use the parent `EuiColorPicker` component instead ([#7460](elastic/eui#7460)) - Remove unused public `EuiCommentTimeline` subcomponent export. Use the parent `EuiComment` or `EuiCommentList` components instead. ([#7467](elastic/eui#7467))
…76030) ## Summary This PR reverts the `onResizeEnd` stable callback workaround introduced in #174955 to account for an EUI bug now that elastic/eui#7468 has been merged and Kibana was upgraded to v92.2.1 in #175849. ### Checklist - [ ] Any text added follows [EUI's writing guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses sentence case text and includes [i18n support](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md) - [ ] [Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html) was added for features that require explanation or tutorials - [ ] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios - [ ] [Flaky Test Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was used on any tests changed - [ ] Any UI touched in this PR is usable by keyboard only (learn more about [keyboard accessibility](https://webaim.org/techniques/keyboard/)) - [ ] Any UI touched in this PR does not create any new axe failures (run axe in browser: [FF](https://addons.mozilla.org/en-US/firefox/addon/axe-devtools/), [Chrome](https://chrome.google.com/webstore/detail/axe-web-accessibility-tes/lhdoppojpmngadmnindnejefpokejbdd?hl=en-US)) - [ ] If a plugin configuration key changed, check if it needs to be allowlisted in the cloud and added to the [docker list](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker) - [ ] This renders correctly on smaller devices using a responsive layout. (You can test this [in your browser](https://www.browserstack.com/guide/responsive-testing-on-local-server)) - [ ] This was checked for [cross-browser compatibility](https://www.elastic.co/support/matrix#matrix_browsers) ### For maintainers - [ ] This was checked for breaking API changes and was [labeled appropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)
…astic#176030) ## Summary This PR reverts the `onResizeEnd` stable callback workaround introduced in elastic#174955 to account for an EUI bug now that elastic/eui#7468 has been merged and Kibana was upgraded to v92.2.1 in elastic#175849. ### Checklist - [ ] Any text added follows [EUI's writing guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses sentence case text and includes [i18n support](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md) - [ ] [Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html) was added for features that require explanation or tutorials - [ ] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios - [ ] [Flaky Test Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was used on any tests changed - [ ] Any UI touched in this PR is usable by keyboard only (learn more about [keyboard accessibility](https://webaim.org/techniques/keyboard/)) - [ ] Any UI touched in this PR does not create any new axe failures (run axe in browser: [FF](https://addons.mozilla.org/en-US/firefox/addon/axe-devtools/), [Chrome](https://chrome.google.com/webstore/detail/axe-web-accessibility-tes/lhdoppojpmngadmnindnejefpokejbdd?hl=en-US)) - [ ] If a plugin configuration key changed, check if it needs to be allowlisted in the cloud and added to the [docker list](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker) - [ ] This renders correctly on smaller devices using a responsive layout. (You can test this [in your browser](https://www.browserstack.com/guide/responsive-testing-on-local-server)) - [ ] This was checked for [cross-browser compatibility](https://www.elastic.co/support/matrix#matrix_browsers) ### For maintainers - [ ] This was checked for breaking API changes and was [labeled appropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)
`v92.1.1`⏩`v92.2.1` --- ## [`v92.2.1`](https://github.com/elastic/eui/releases/v92.2.1) **Bug fixes** - Removed unintentional i18n tokens in prior release that should not have been exported ## [`v92.2.0`](https://github.com/elastic/eui/releases/v92.2.0) - Updated `EuiFlyoutResizable` with new optional `onResize` callback ([elastic#7464](elastic/eui#7464)) **Bug fixes** - Fixed an issue in `EuiResizableContainer` where `onResizeEnd` could become a stale closure when renders occured between resize start and end, resulting in an outdated version of a consumer's `onResizeEnd` callback being called ([elastic#7468](elastic/eui#7468)) - Fixed `EuiTextArea` to correctly fire `onChange` callbacks on clear button click ([elastic#7473](elastic/eui#7473)) - Fixed `EuiContextMenu`'s panel titles & items to not show underlines on hover for non-interactive elements ([elastic#7474](elastic/eui#7474)) **Deprecations** - Remove unused public `EuiHue` and `EuiSaturation` subcomponent exports. Use the parent `EuiColorPicker` component instead ([elastic#7460](elastic/eui#7460)) - Remove unused public `EuiCommentTimeline` subcomponent export. Use the parent `EuiComment` or `EuiCommentList` components instead. ([elastic#7467](elastic/eui#7467))
…astic#176030) ## Summary This PR reverts the `onResizeEnd` stable callback workaround introduced in elastic#174955 to account for an EUI bug now that elastic/eui#7468 has been merged and Kibana was upgraded to v92.2.1 in elastic#175849. ### Checklist - [ ] Any text added follows [EUI's writing guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses sentence case text and includes [i18n support](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md) - [ ] [Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html) was added for features that require explanation or tutorials - [ ] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios - [ ] [Flaky Test Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was used on any tests changed - [ ] Any UI touched in this PR is usable by keyboard only (learn more about [keyboard accessibility](https://webaim.org/techniques/keyboard/)) - [ ] Any UI touched in this PR does not create any new axe failures (run axe in browser: [FF](https://addons.mozilla.org/en-US/firefox/addon/axe-devtools/), [Chrome](https://chrome.google.com/webstore/detail/axe-web-accessibility-tes/lhdoppojpmngadmnindnejefpokejbdd?hl=en-US)) - [ ] If a plugin configuration key changed, check if it needs to be allowlisted in the cloud and added to the [docker list](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker) - [ ] This renders correctly on smaller devices using a responsive layout. (You can test this [in your browser](https://www.browserstack.com/guide/responsive-testing-on-local-server)) - [ ] This was checked for [cross-browser compatibility](https://www.elastic.co/support/matrix#matrix_browsers) ### For maintainers - [ ] This was checked for breaking API changes and was [labeled appropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)
`v92.1.1`⏩`v92.2.1` --- ## [`v92.2.1`](https://github.com/elastic/eui/releases/v92.2.1) **Bug fixes** - Removed unintentional i18n tokens in prior release that should not have been exported ## [`v92.2.0`](https://github.com/elastic/eui/releases/v92.2.0) - Updated `EuiFlyoutResizable` with new optional `onResize` callback ([elastic#7464](elastic/eui#7464)) **Bug fixes** - Fixed an issue in `EuiResizableContainer` where `onResizeEnd` could become a stale closure when renders occured between resize start and end, resulting in an outdated version of a consumer's `onResizeEnd` callback being called ([elastic#7468](elastic/eui#7468)) - Fixed `EuiTextArea` to correctly fire `onChange` callbacks on clear button click ([elastic#7473](elastic/eui#7473)) - Fixed `EuiContextMenu`'s panel titles & items to not show underlines on hover for non-interactive elements ([elastic#7474](elastic/eui#7474)) **Deprecations** - Remove unused public `EuiHue` and `EuiSaturation` subcomponent exports. Use the parent `EuiColorPicker` component instead ([elastic#7460](elastic/eui#7460)) - Remove unused public `EuiCommentTimeline` subcomponent export. Use the parent `EuiComment` or `EuiCommentList` components instead. ([elastic#7467](elastic/eui#7467))
…astic#176030) ## Summary This PR reverts the `onResizeEnd` stable callback workaround introduced in elastic#174955 to account for an EUI bug now that elastic/eui#7468 has been merged and Kibana was upgraded to v92.2.1 in elastic#175849. ### Checklist - [ ] Any text added follows [EUI's writing guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses sentence case text and includes [i18n support](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md) - [ ] [Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html) was added for features that require explanation or tutorials - [ ] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios - [ ] [Flaky Test Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was used on any tests changed - [ ] Any UI touched in this PR is usable by keyboard only (learn more about [keyboard accessibility](https://webaim.org/techniques/keyboard/)) - [ ] Any UI touched in this PR does not create any new axe failures (run axe in browser: [FF](https://addons.mozilla.org/en-US/firefox/addon/axe-devtools/), [Chrome](https://chrome.google.com/webstore/detail/axe-web-accessibility-tes/lhdoppojpmngadmnindnejefpokejbdd?hl=en-US)) - [ ] If a plugin configuration key changed, check if it needs to be allowlisted in the cloud and added to the [docker list](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker) - [ ] This renders correctly on smaller devices using a responsive layout. (You can test this [in your browser](https://www.browserstack.com/guide/responsive-testing-on-local-server)) - [ ] This was checked for [cross-browser compatibility](https://www.elastic.co/support/matrix#matrix_browsers) ### For maintainers - [ ] This was checked for breaking API changes and was [labeled appropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)
Summary
This PR fixes an issue where
onResizeEnd
becomes a stale closure when renders occur between resize start and end. This can result in an outdated version of a consumer'sonResizeEnd
callback being called on resize end.QA
General checklist
- [ ] Checked in both light and dark modes- [ ] Checked in mobile- [ ] Checked for accessibility including keyboard-only and screenreader modesand cypress tests- [ ] If applicable, added the breaking change issue label (and filled out the breaking change checklist)