-
Notifications
You must be signed in to change notification settings - Fork 843
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
[EuiAccordion] Fix resize observer loop error when drag&dropping an accordion #6031
[EuiAccordion] Fix resize observer loop error when drag&dropping an accordion #6031
Conversation
…ptimizing the ref callback
Preview documentation changes for this PR: https://eui.elastic.co/pr_6031/ |
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.
Inline ref
callback loop was a great find! Glad we don't need a resizeObserver intervention.
Tested with the docs deployment with the specific sizing + zoom.
CI error is from an AXE error in the reproduction case and will be resolved when the revert commit is reverted |
Agreed, this is a super elegant fix/workaround to the problem! Huge kudos! |
Co-authored-by: Constance <constancecchen@users.noreply.github.com>
This reverts commit fa3f198.
Preview documentation changes for this PR: https://eui.elastic.co/pr_6031/ |
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 good with this! This is such an edge case I honestly don't think it needs a unit test or Cypress test specifically written for it, nor am I totally sure how we would write one 👍
Summary
Closes #5903
Found this by attempting to automatically pause/resume all EuiResizeObserver/useResizeObserver in response to drag&drop events. Was debugging why the error still happened with everything paused, at it turned out the re-renders in EuiAccordion were recreating the provided
ref
function causing React to call that function withnull
and then the sameElement
as it was before. This behaviour bypassedEuiObserver::updateChildNode
's 'memoizing' logic and instantiated new observers during the drag operation.After fixing the ref call loop the error went away even without pausing the observers 🎆
Reproduction & testing:
I updated the Drag and drop example page to have only the reproduction setup, you must also enable devtools' responsive layout, select ipad mini, and set the zoom level to 75%.
resizeobserveraccordion.mov
Checklist
- [ ] Checked 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 any docs examples- [ ] Added or updated jest and cypress tests- [ ] Updated the Figma library counterpart