Skip to content

fix: measure TabPanels after nested content renders and stop size variable inheritance - #10819

Open
jsabutis wants to merge 3 commits into
adobe:mainfrom
jsabutis:fix/nested-tabs-height-10292
Open

jsabutis wants to merge 3 commits into
adobe:mainfrom
jsabutis:fix/nested-tabs-height-10292

Conversation

@jsabutis

Copy link
Copy Markdown

Closes #10292

TabPanels measures its new size in the same commit that mounts the new panel. A nested Tabs has not rendered its TabList and TabPanel yet at that point, so the outer panel animates to the wrong height and snaps when it resets to auto. Also, --tab-panel-height and --tab-panel-width are only set on the outer TabPanels during the animation, so a nested TabPanels inherits the outer pixel value.

The fix measures and starts the transition in a requestAnimationFrame scheduled from the layout effect (still before paint, after the nested collection has flushed), and makes every TabPanels define both variables inline as auto. #10293 only changed the inheritance, which is why it had no visible effect.

✅ Pull Request Checklist:

  • Included link to corresponding React Spectrum GitHub Issue.
  • Added/updated unit tests and storybook for this change (for new code or code which already has tests).
  • Filled out test instructions.
  • Updated documentation (if it already exists for this component).
  • Looked at the Accessibility Practices for this feature - Aria Practices
  • I understand every change in this PR and can explain why it's there.
  • If AI-assisted, I followed our AI contribution guidance and pointed my assistant at AGENTS.md.

📝 Test Instructions:

New browser test in Tabs.browser.test.tsx (outer panel 50px, nested Tabs with a 100px panel): passes in Chromium, Firefox and WebKit, fails on main. Jest Tabs suites: 44/44.

Manually: yarn start-parcel3, open react-aria-components-tabs--nested-tabs-animated, click Foo, Bar, Baz. On main the outer panel jumps up to 107px in one frame and snaps at the end; here every switch eases to its settled height. Before/after recording attached.

🧢 Your Project:

Nclusion

…iable inheritance

TabPanels measured its new size in the same commit that mounted the new
panel, before a nested Tabs had rendered its TabList and selected
TabPanel, so it animated to the wrong height and snapped at the end.
Measure in the next animation frame instead, which still runs before
paint.

Also define --tab-panel-width/height on every TabPanels so a nested
TabPanels does not inherit the outer pixel values mid-transition.

Fixes adobe#10292
@snowystinger

Copy link
Copy Markdown
Member

You'll need to sign the CLA https://github.com/adobe/react-spectrum/blob/main/CONTRIBUTING.md#contributor-license-agreement

Looks promising. Tested in Chrome and it appears to work well, no more expanding the wrong way then jumping to the final size.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Nested Tabs height transitions break due to CSS variable bleed and 0-height behavior of TabList and TabPanel

2 participants