Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 29, 2026

The test helpers were using tabIndex={tabObj.tabpanel?.tabIndex ?? 0} as a workaround for failing tests. This was misdiagnosed as a JSDOM bug, but the actual issue was that explicitly passing tabIndex={undefined} overrides Base UI's internal default (tabIndex: hidden ? -1 : 0).

Changes

  • Replace ?? 0 workaround with conditional prop spreading in UncontrolledTabs and ControlledTabs test helpers
  • Only pass tabIndex prop when explicitly defined in test data, allowing Base UI's defaults to apply
// Before: Forces tabIndex={0}, overriding Base UI behavior
<Tabs.Panel tabIndex={tabObj.tabpanel?.tabIndex ?? 0} />

// After: Omits prop when undefined, preserving Base UI defaults
<Tabs.Panel
  {...(tabObj.tabpanel?.tabIndex !== undefined && {
    tabIndex: tabObj.tabpanel.tabIndex,
  })}
/>

This allows Base UI to manage focusability by default while still supporting explicit overrides (e.g., tabIndex: -1 for non-tabbable panels).


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 2 commits January 29, 2026 18:14
Instead of using `?? 0` which was a workaround for JSDOM, the proper fix is to only pass the tabIndex prop when it's explicitly defined. This allows Base UI's default tabIndex behavior (0 for visible panels, -1 for hidden) to work correctly when no custom tabIndex is specified.

Co-authored-by: ciampo <[email protected]>
Address code review feedback by updating the remaining instance of direct tabIndex assignment to use the same conditional spreading pattern for consistency.

Co-authored-by: ciampo <[email protected]>
Copy link
Contributor Author

Copilot AI commented Jan 29, 2026

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • translate.wordpress.org
    • Triggering command: /usr/local/bin/node node i18n-cache/index.js (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI changed the title [WIP] Work in progress on adding Tabs component in @wordpress/ui Fix tabIndex prop handling in Tabs test helpers Jan 29, 2026
Copilot AI requested a review from ciampo January 29, 2026 18:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants