[EuiAccordion] Fix resize observer loop error when drag&dropping an accordion#6031
Merged
chandlerprall merged 6 commits intoelastic:mainfrom Jul 6, 2022
Merged
Conversation
…ptimizing the ref callback
|
Preview documentation changes for this PR: https://eui.elastic.co/pr_6031/ |
thompsongl
approved these changes
Jul 6, 2022
Contributor
thompsongl
left a comment
There was a problem hiding this comment.
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.
Contributor
Author
|
CI error is from an AXE error in the reproduction case and will be resolved when the revert commit is reverted |
Contributor
|
Agreed, this is a super elegant fix/workaround to the problem! Huge kudos! |
cee-chen
reviewed
Jul 6, 2022
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/ |
cee-chen
approved these changes
Jul 6, 2022
6 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
reffunction causing React to call that function withnulland then the sameElementas 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