fix(ui-modal): avoid redundant Modal.Body re-renders from its observers - #2701
Open
balzss wants to merge 1 commit into
Open
fix(ui-modal): avoid redundant Modal.Body re-renders from its observers#2701balzss wants to merge 1 commit into
balzss wants to merge 1 commit into
Conversation
The resize and mutation observers called forceUpdate() on every observed change, re-rendering even when the derived tabIndex was identical. Derive needsTabIndex into state and compare before calling setState, which also stops the act() warnings consumers see in jsdom test suites. Applies to v1 and v2. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Contributor
|
Contributor
Visual regression reportCypress suite: ✅ Passing Visual diff: ✅ No changes.
Accessibility (axe): ✅ No violations. 📊 View full report — click a screenshot's ⚠ badge to see each violation boxed on the image, with the offending element named and contrast failures shown as color swatches. Baselines come from the |
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
Modal.Body's resize/mutation observers calledforceUpdate()on every observed change, so any DOM change inside the body re-rendered it even when the derivedtabIndexwas identical. In jsdom test suites those updates land outsideact(), which is what consumers on 11.7.4 are seeing.needsTabIndexinto state and compare against the last computed value before callingsetState. The comparison has to precedesetState— for class components it schedules (and warns) before the updater runs, so bailing out inside the updater is too late.render()no longer reads live DOM geometry; it reads state, and the DOM reads moved intosyncTabIndex.Measured on the branch: 20 no-op mutations inside the body went from 20 re-renders to 0 (real Chromium), and 10 mutations from 10 act warnings to 0 (jsdom + RTL, both versions).
Test Plan
aria-label, since this touches the same code path as INSTUI-5046.Fixes INSTUI-5166
🤖 Generated with Claude Code