Skip to content

Select tab panel when caret moves into tab#79558

Merged
Mamaduka merged 2 commits into
trunkfrom
fix/select-tab-panel-on-focus
Jun 26, 2026
Merged

Select tab panel when caret moves into tab#79558
Mamaduka merged 2 commits into
trunkfrom
fix/select-tab-panel-on-focus

Conversation

@jeryj

@jeryj jeryj commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

What?

Updates the Tabs block so that moving the caret into a tab's label in the editor activates that tab's panel, matching the existing click behavior.

Why?

In the editor, the active tab panel only switched when you clicked a tab. Moving the caret into a different tab label with the keyboard left the previously selected panel showing — you had to click in the editor to update which panel was visible. This is inconsistent and breaks keyboard-only editing of tabs.

How?

All tab labels live as RichText fields inside a single core/tab-list block, so moving the caret between labels with the keyboard never changes the selected block and never fired the existing click/selection handlers that update the active panel.

In tab-list/edit.js:

  • Renamed handleTabClick to selectTabPanel, since it sets the active panel regardless of how it's triggered.
  • Replaced the onClick handler with an onFocus handler on each tab button that calls selectTabPanel( index ). React's onFocus bubbles (via focusin) from the inner RichText editable, so focus landing in a tab label activates the matching panel.

selectTabPanel already no-ops when the target tab is already active and marks the change as non-persistent (kept out of undo history), so the added onFocus is safe alongside the click path.

Testing Instructions

  1. Add a Tabs block to a post with at least two tabs, each with distinct panel content.
  2. Click into the first tab's label — confirm the first panel is shown.
  3. Without clicking the editor canvas, move the caret into the second tab's label (see keyboard steps below).
  4. Confirm the second tab's panel becomes the visible/active panel as soon as the caret enters its label.

Testing Instructions for Keyboard

  1. Add a Tabs block with two or more tabs.
  2. Place the caret in the first tab's label and edit its text.
  3. Use the arrow keys to move the caret from the first tab label into the next tab label.
  4. Confirm the panel updates to the newly focused tab without needing a mouse click.

Screenshots or screencast

Before After

Use of AI Tools

I used Claude Code to investigate the cause and draft the change.

@github-actions github-actions Bot added the [Package] Block library /packages/block-library label Jun 25, 2026
@github-actions

github-actions Bot commented Jun 25, 2026

Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: jeryj <jeryj@git.wordpress.org>
Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@github-actions

github-actions Bot commented Jun 25, 2026

Copy link
Copy Markdown

Size Change: -7 B (0%)

Total Size: 7.49 MB

📦 View Changed
Filename Size Change
build/scripts/block-library/index.min.js 324 kB -7 B (0%)

compressed-size-action

…ractions

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@jeryj jeryj self-assigned this Jun 25, 2026
@jeryj jeryj added [Block] Tabs Affects the Tabs Block [Type] Bug An existing feature does not function as intended labels Jun 25, 2026
@jeryj jeryj requested review from Mamaduka and t-hamano June 25, 2026 19:49

@Mamaduka Mamaduka left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks, @jeryj!

@Mamaduka Mamaduka merged commit 20985f8 into trunk Jun 26, 2026
52 of 53 checks passed
@Mamaduka Mamaduka deleted the fix/select-tab-panel-on-focus branch June 26, 2026 04:57
@github-actions github-actions Bot added this to the Gutenberg 23.6 milestone Jun 26, 2026
SainathPoojary pushed a commit to SainathPoojary/gutenberg that referenced this pull request Jun 29, 2026
Co-authored-by: jeryj <jeryj@git.wordpress.org>
Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Block] Tabs Affects the Tabs Block [Package] Block library /packages/block-library [Type] Bug An existing feature does not function as intended

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants