close
Skip to content

Tab List: Add toolbar buttons to reorder tabs - #80107

Merged
t-hamano merged 8 commits into
trunkfrom
tabs-list-mover
Jul 15, 2026
Merged

Tab List: Add toolbar buttons to reorder tabs#80107
t-hamano merged 8 commits into
trunkfrom
tabs-list-mover

Conversation

@t-hamano

@t-hamano t-hamano commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Depends on #80031

What?

Since tab panels are blocks, they can be reordered by default, and reordering the tab panels propagates to the order of the tab list. However, the reverse is not possible. It would be convenient if the reverse direction, i.e., reordering could also be performed on the tab list.

How?

  • Inject a custom mover component to the block toolbar.
  • Add moveTab action to the useTabActions hook

Testing Instructions

  • Insert a Tabs block.
  • Click any tab to activate it.
  • Use the block toolbar buttons to move tabs left or right.
  • The order of the tab panels should change as you rearrange the tabs.

Screenshots or screencast

tab-order.mp4

@github-actions github-actions Bot added the [Package] Block library /packages/block-library label Jul 10, 2026
Comment on lines +4 to +9
.wp-block-tab-list__mover-button {
@include break-small() {
width: $button-size-small;
min-width: 0 !important;
}
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The button needs to resize according to the viewport, similar to the block mover button.

Image Image

@github-actions

github-actions Bot commented Jul 10, 2026

Copy link
Copy Markdown

Size Change: +2.64 kB (+0.03%)

Total Size: 7.72 MB

📦 View Changed
Filename Size Change
build/scripts/block-library/index.min.js 350 kB +320 B (+0.09%)
build/styles/block-library/editor-rtl.css 12.8 kB +19 B (+0.15%)
build/styles/block-library/editor-rtl.min.css 10.5 kB +20 B (+0.19%)
build/styles/block-library/editor.css 12.8 kB +19 B (+0.15%)
build/styles/block-library/editor.min.css 10.4 kB +21 B (+0.2%)
build/styles/block-library/tab-list/editor-rtl.css 1.02 kB +1.02 kB (new file) 🆕
build/styles/block-library/tab-list/editor-rtl.min.css 100 B +100 B (new file) 🆕
build/styles/block-library/tab-list/editor.css 1.02 kB +1.02 kB (new file) 🆕
build/styles/block-library/tab-list/editor.min.css 100 B +100 B (new file) 🆕

compressed-size-action

@t-hamano t-hamano changed the title Tabs list mover Tab List: Add toolbar buttons to reorder tabs left and right Jul 10, 2026
@t-hamano t-hamano changed the title Tab List: Add toolbar buttons to reorder tabs left and right Tab List: Add toolbar buttons to reorder tabs Jul 10, 2026
@t-hamano t-hamano added [Type] Enhancement A suggestion for improvement. [Block] Tabs Affects the Tabs Block labels Jul 10, 2026
@t-hamano t-hamano self-assigned this Jul 10, 2026
@github-actions

github-actions Bot commented Jul 11, 2026

Copy link
Copy Markdown

Flaky tests detected in 5f6d774.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/29391189897
📝 Reported issues:

@t-hamano
t-hamano requested review from Mamaduka and jeryj July 11, 2026 11:38
@t-hamano
t-hamano marked this pull request as ready for review July 11, 2026 11:38
@github-actions

github-actions Bot commented Jul 11, 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: t-hamano <wildworks@git.wordpress.org>
Co-authored-by: jeryj <jeryj@git.wordpress.org>
Co-authored-by: ciampo <mciampini@git.wordpress.org>
Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>
Co-authored-by: noruzzamans <noruzzaman@git.wordpress.org>

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

@noruzzamans

Copy link
Copy Markdown
Contributor

Hi @t-hamano I tested this PR locally, and the tab reordering controls work perfectly in both the editor and the frontend.

Screen.Recording.2026-07-12.at.1.47.44.PM.mov

@github-actions github-actions Bot added [Package] Interface /packages/interface [Package] Icons /packages/icons [Package] Edit Site /packages/edit-site [Package] Base styles /packages/base-styles [Package] Preferences /packages/preferences [Package] Media Utils /packages/media-utils [Package] Commands /packages/commands [Package] DataViews /packages/dataviews [Package] Fields /packages/fields [Package] Theme /packages/theme [Package] UI /packages/ui labels Jul 14, 2026
@t-hamano
t-hamano changed the base branch from fix/tabs-label-source-of-truth to trunk July 14, 2026 10:20
@t-hamano

Copy link
Copy Markdown
Contributor Author

Apologize for the widespread notifications. I temporarily failed the rebase.

@t-hamano t-hamano mentioned this pull request Jul 14, 2026
14 tasks

@jeryj jeryj left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Functioning well! I think this is a big UX improvement. I'm approving, but I think we need to update the labels to match the icons with the isRTL check.

<ToolbarButton
className="wp-block-tab-list__mover-button"
icon={ isRTL() ? chevronRight : chevronLeft }
label={ __( 'Move tab left' ) }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should these labels also get the isRTL check?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

image

You're right, this label needs to be flipped as well.

Fixed in 09637ca

@jeryj

jeryj commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

I merged the upstream in to get the tests to restart since they were all stalled.

The mover icons already flip based on isRTL(), but the labels stayed
"Move tab left"/"Move tab right", so in RTL locales the label described
the opposite of the direction the tab actually moves. Swap the labels to
match the icons and the visual movement.

Co-Authored-By: Claude <noreply@anthropic.com>
@t-hamano

Copy link
Copy Markdown
Contributor Author

@jeryj Thanks for the review!

I would like to backport this PR to 7.1 because it does not introduce any new APIs and simply improves usability.

@jeryj

jeryj commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

would like to backport this PR to 7.1 because it does not introduce any new APIs and simply improves usability.

I agree. I think this would really improve the usability for people wanting to reorder the tabs.

@ciampo ciampo Jul 14, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

One way to avoid having to say "right" and "left" is to use words such as "previous" and "next", or "before" and "after", etc

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

That sounds like a good simplification to me!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Nice idea! Let's adopt that word.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 6ba3ae2

LTR

image image

RTL

image image

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.

A clever solution.

t-hamano and others added 2 commits July 15, 2026 11:34
The mover button labels used "left"/"right", which are direction-relative
and required flipping in RTL. Use "before"/"after" instead so the labels
read correctly regardless of writing direction, and drop the RTL label
flip. Chevron icons still flip for RTL.

Co-Authored-By: Claude <noreply@anthropic.com>
Follow up to the direction-neutral mover labels: the E2E tests still
clicked "Move tab left"/"Move tab right", which no longer exist. Use the
new "Move tab before"/"Move tab after" labels so the tests pass.

Co-Authored-By: Claude <noreply@anthropic.com>

@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.

This test well for me. Thanks, @t-hamano!

@t-hamano

Copy link
Copy Markdown
Contributor Author

Going to merge this, as a failing unit test is a known issue.

https://wordpress.slack.com/archives/C02QB2JS7/p1784093340358909

@github-actions

Copy link
Copy Markdown

I just cherry-picked this PR to the wp/7.1 branch to get it included in the next release: 4415a6b

@t-hamano

Copy link
Copy Markdown
Contributor Author

I just cherry-picked this PR to the release/23.6 branch to get it included in the next release: 5261fa7

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

Labels

Backported to WP Core Pull request that has been successfully merged into WP Core [Block] Tabs Affects the Tabs Block [Package] Block library /packages/block-library [Type] Enhancement A suggestion for improvement.

Projects

Development

Successfully merging this pull request may close these issues.

5 participants