Skip to content

Conversation

@beaesguerra
Copy link
Member

@beaesguerra beaesguerra commented Dec 3, 2025

Summary:

There was an issue reported by Level Access where a tabpanel had tabindex=0 in the Classroom Teacher Settings page, even though the tabpanel had focusable content. This was because the tab panel contents go from a loading state with no focusable elements, to UI with focusable elements.

To address this, we set up a MutationObserver on the tab panel. When a tab panel is active, it will observe any changes in its subtree and re-determine if the tab panel contains focusable elements. This will make sure the tabindex is set properly depending on if there is or isn't focusable content in the panel

Issue: WB-2171

Test plan:

Storybook:

  1. Navigate to ?path=/story/packages-tabs-tabs--with-focusable-content
  2. Select the "Content with no focusable elements at first" tab. Press "tab" to make sure the tab panel is focusable while it is loading. Press "shift+tab" to focus back on the active tab
  3. Once it is done loading, tab through the Tabs component and make sure the tab panel is not focusable

Before:

Screen.Recording.2025-12-03.at.4.51.15.PM.mov

After:

Screen.Recording.2025-12-03.at.4.49.50.PM.mov

Frontend znd using npm snapshot:

Regression testing:

  • Test other Tabs stories to confirm things continue to work as expected
    • Other cases for focusable content in /?path=/story/packages-tabs-tabs--with-focusable-content
    • Playtesting stories /?path=/docs/packages-tabs-tabs-testing-tabs-playtesting--docs

@changeset-bot
Copy link

changeset-bot bot commented Dec 3, 2025

🦋 Changeset detected

Latest commit: 15e1655

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@khanacademy/wonder-blocks-tabs Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions
Copy link
Contributor

github-actions bot commented Dec 3, 2025

Size Change: +60 B (+0.06%)

Total Size: 109 kB

Filename Size Change
packages/wonder-blocks-tabs/dist/es/index.js 3.8 kB +60 B (+1.6%)
ℹ️ View Unchanged
Filename Size
packages/wonder-blocks-accordion/dist/es/index.js 3 kB
packages/wonder-blocks-announcer/dist/es/index.js 1.74 kB
packages/wonder-blocks-badge/dist/es/index.js 2.02 kB
packages/wonder-blocks-banner/dist/es/index.js 2.01 kB
packages/wonder-blocks-birthday-picker/dist/es/index.js 1.92 kB
packages/wonder-blocks-breadcrumbs/dist/es/index.js 755 B
packages/wonder-blocks-button/dist/es/index.js 4.25 kB
packages/wonder-blocks-card/dist/es/index.js 1.06 kB
packages/wonder-blocks-cell/dist/es/index.js 2.18 kB
packages/wonder-blocks-clickable/dist/es/index.js 2.66 kB
packages/wonder-blocks-core/dist/es/index.js 2.48 kB
packages/wonder-blocks-data/dist/es/index.js 5.48 kB
packages/wonder-blocks-dropdown/dist/es/index.js 19.4 kB
packages/wonder-blocks-form/dist/es/index.js 6.2 kB
packages/wonder-blocks-grid/dist/es/index.js 1.24 kB
packages/wonder-blocks-icon-button/dist/es/index.js 3.2 kB
packages/wonder-blocks-icon/dist/es/index.js 1.91 kB
packages/wonder-blocks-labeled-field/dist/es/index.js 3.48 kB
packages/wonder-blocks-layout/dist/es/index.js 1.63 kB
packages/wonder-blocks-link/dist/es/index.js 1.52 kB
packages/wonder-blocks-modal/dist/es/index.js 7.06 kB
packages/wonder-blocks-pill/dist/es/index.js 1.31 kB
packages/wonder-blocks-popover/dist/es/index.js 4.3 kB
packages/wonder-blocks-progress-spinner/dist/es/index.js 1.48 kB
packages/wonder-blocks-search-field/dist/es/index.js 1.1 kB
packages/wonder-blocks-styles/dist/es/index.js 464 B
packages/wonder-blocks-switch/dist/es/index.js 1.55 kB
packages/wonder-blocks-testing-core/dist/es/index.js 3.25 kB
packages/wonder-blocks-testing/dist/es/index.js 978 B
packages/wonder-blocks-theming/dist/es/index.js 384 B
packages/wonder-blocks-timing/dist/es/index.js 1.37 kB
packages/wonder-blocks-tokens/dist/es/index.js 5.01 kB
packages/wonder-blocks-toolbar/dist/es/index.js 906 B
packages/wonder-blocks-tooltip/dist/es/index.js 6.4 kB
packages/wonder-blocks-typography/dist/es/index.js 1.57 kB

compressed-size-action

@github-actions
Copy link
Contributor

github-actions bot commented Dec 3, 2025

npm Snapshot: Published

🎉 Good news!! We've packaged up the latest commit from this PR (49ddfe1) and published all packages with changesets to npm.

You can install the packages in frontend by running:

./dev/tools/deploy_wonder_blocks.js --tag="PR2888"

Packages can also be installed manually by running:

pnpm add @khanacademy/wonder-blocks-<package-name>@PR2888

@github-actions
Copy link
Contributor

github-actions bot commented Dec 3, 2025

A new build was pushed to Chromatic! 🚀

https://5e1bf4b385e3fb0020b7073c-zkpdojvfdo.chromatic.com/

Chromatic results:

Metric Total
Captured snapshots 3
Tests with visual changes 0
Total stories 747
Inherited (not captured) snapshots [TurboSnap] 445
Tests on the build 448

@codecov
Copy link

codecov bot commented Dec 3, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 0.00%. Comparing base (5203e43) to head (264a11c).

Additional details and impacted files

Impacted file tree graph

@@              Coverage Diff              @@
##   fix-popover-with-tabs   #2888   +/-   ##
=============================================
=============================================

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5203e43...264a11c. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@beaesguerra beaesguerra marked this pull request as ready for review December 4, 2025 00:00
@khan-actions-bot khan-actions-bot requested a review from a team December 4, 2025 00:01
@khan-actions-bot
Copy link
Contributor

Gerald

Required Reviewers
  • @Khan/wonder-blocks for changes to .changeset/mean-tomatoes-dress.md, __docs__/wonder-blocks-tabs/tabs.stories.tsx, packages/wonder-blocks-tabs/src/components/tab-panel.tsx, packages/wonder-blocks-tabs/src/components/__tests__/tab-panel.test.tsx

Don't want to be involved in this pull request? Comment #removeme and we won't notify you of further changes.

Base automatically changed from fix-popover-with-tabs to main December 4, 2025 18:09
@beaesguerra beaesguerra force-pushed the fix-tabs-panel-children-changing branch from 26fd6fd to 9a023f2 Compare December 4, 2025 18:25
Copy link
Member

@jandrade jandrade left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! This is a neat implementation! 🚀

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

praise: This example is great to illustrate this point!

Comment on lines 160 to 165
/**
* When a tab panel has focusable elements, pressing `Tab` from the tablist
* will move focus to the first focusable element in the tab panel. If there
* are no focusable elements in the active tab panel, the tab panel will be
* focused instead.
*/
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: It would be super helpful to explain this new behavior in the docs :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated, thanks for the suggestion!

…ing focusability when descendant elements change
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.

4 participants