Repository navigation
[composite] Check the tab stop's visibility in the frame after mount - #6247
Open
arimendelow wants to merge 3 commits into
Open
arimendelow wants to merge 3 commits into
arimendelow wants to merge 3 commits into
Conversation
arimendelow
requested review from
atomiks,
colmtuite,
flaviendelangle,
jjenzz and
michaldudak
as code owners
November 15, 2026 11:02
commit: |
Bundle size
PerformanceNo regressions in 36 benchmarks · ran 3m 19s · details Check out the code infra dashboard for more information about this PR. |
✅ Deploy Preview for base-ui ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify project configuration. |
This branch has not been deployed
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.
Fixes #6239.
Problem
When a composite mounts (Toggle Group, Toolbar, Navigation Menu, Radio Group with no value, Menubar, and any
CompositeRootwithout an active item),useCompositeRoot'sonMapChangechecks whether the default tab stop can hold focus withisListIndexDisabled. That callsisElementVisible, which runsgetComputedStyleandcheckVisibility(). It runs in the layout phase of the commit that mounts the composite, while the DOM has pending changes, so the browser recalculates style (and layout, forcheckVisibility) for the whole document before the first paint. ThedisabledIndiceslayout effect does the same each timedisabledIndiceschanges, which Toolbar does after every item map change.On a busy screen that is a forced style recalculation per composite. In one app's call screen at 4× CPU, composite registration was about 30% of the worst main-thread block.
Change
isListIndexDisabledis split:isListIndexDisabledByAttributesholds the checks that read no style (disabledIndices,:disabled,aria-disabled/data-disabled);isListIndexDisabledis that plus the visibility check, unchanged in result.disabledIndiceseffect, the attribute checks still run in the commit, so a disabled default item never holds the tab stop in the first frame.tabindex="0"for one frame, while it can't be seen or reached.Measured
A minimal Vite app with Base UI built from source, mounting each composite inside
flushSyncin Chromium and countinggetComputedStylecalls during the mount:visibility: hiddenTab stops (
tabindexof each item) are unchanged after the next frame: a hidden first toggle ends on the second (-1,0,-1), a disabled first toggle moves at mount (-1,0), and the Toolbar case is the same as master.Tests
aria-disabledfirst item loses it in the mount commit.skips items that cannot hold the tab stopnow waits for the frame before checking the first tab stop, since its first item isdisplay: none.An earlier attempt at the same reads, #6134, was closed by its author without review.