Repository navigation
CodeQuality: Tab List: Remove the unused tabIndex context from the tab buttons - #86432
Conversation
🤖 PR meta 🤖🎉 PropsIf you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. Props Bot commandsYou can trigger Props Bot actions by commenting on this PR:
Updated as activity occurs, without notifying anyone named here. Add the |
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are recorded for the unused tab-button context removal and related docblock update.
No open issues 🎉
What changed in this PR
Removes unused per-button Interactivity API context from the Tab List render callback, cleaning up a leftover from the Tab block removal in #77439.
Changes:
- Removes the
data-wp-contextattribute containingtabIndexfrom tab buttons. - Updates the callback’s docblock to match the remaining attributes.
| File | Description |
|---|---|
packages/block-library/src/tab-list/index.php |
Removes unused button context and updates the docblock. |
Review effort: Balanced
|
Hi @t-hamano, Sorry for the ping and much of the PRs to review 😅. Can you check the small code quality improvement for this. It's a dead code present in tabs block. Details present in PR description. |
I have not created the issue for the same because of a quick CodeQuality update
What?
Follow-up to #77439
Removes the
data-wp-context='{"tabIndex":N}'directive that the Tab List render callback adds to each tab button.Why?
Nothing reads it.
view.jsonly readstabsIdandactiveTabIndexfrom the context, and thestate.tabIndexgetter works out a tab's index from the button'sidinstead. The context is a leftover from the restructure that removed thecore/tabblock in #77439.How?
set_attribute( 'data-wp-context', … )call fromblock_core_tab_list_render_callback(), and the mention of it in the function's docblock.setActiveTabwritesactiveTabIndexthrough the button's context. The button's own context never had that key, so the Interactivity API already wrote it to the Tabs block's context (proxies/context.ts). Without a button context,getContext()returns the Tabs block's context directly.Tab Panel's
core/tab-labelcontext is also unused in core since #77439, but it's left in place. Block context is a public API, documented in the Tab Panel README, and blocks from other plugins inside a tab panel may read it.Testing Instructions
data-wp-contextattribute.npm run test:e2e -- editor/blocks/tabs.spec.jsTesting Instructions for Keyboard
Step 4 covers the keyboard: reach the tabs with Tab, then use the Arrow, Home and End keys, and Enter or Space.
Use of AI Tools
I used Claude Code (Claude Opus 5.5) to check that the context is unused and to draft the change and this description. I reviewed and tested the changes myself.