Skip to main content
GoodFirstPicks
DashboardIssuesReposLeaderboard

GoodFirstPicks by Leaveitblank © 2026

CreatorRequest a RepoPrivacy PolicyTerms of Service
Tabs component: Selected tab underline can be in the wrong position when a sibling tab changes size | GoodFirstPicks

Tabs component: Selected tab underline can be in the wrong position when a sibling tab changes size

WordPress/gutenberg 1 comments 1mo ago
View on GitHub
mediumopenScope: somewhat clearSkill match: maybeWordPressJavaScriptReact

Why this is a good first issue

The issue involves a UI bug in the tabs component that requires careful handling of tab size changes.

AI Summary

The tabs component's selected tab underline incorrectly positions itself when sibling tabs change size, particularly evident in the site editor. The fix requires updating the underline position logic to account for sibling tab size changes, but the implementation could become complex due to the current code structure.

Issue Description

Description

The tabs component has a fancy animated underline that indicates the selected tab.

Unfortunately the underline can be positioned incorrectly if a sibling tab changes size.

This bug is evident in the site editor when accessing a template part. The block inspector's first tab changes from 'Template' to 'Template Part'. The neighbouring tab moves to the right or left, but the underline stays in place. It can also cause an overflow of the tabs component resulting in a scrollbar.

Looking at the code, it tracks changes to only the selected tab, so if the selected tab doesn't change the underline isn't recomputed: https://github.com/WordPress/gutenberg/blob/9ab818b358f8f884053be7ef3de883730ab3a024/packages/components/src/tabs/tablist.tsx#L92-L94

This is quite a lot already for a little underline, and I think the fix has the potential to make the code too complicated, so I didn't push a PR for it. It might be worth reconsidering some parts of the implementation.

Step-by-step reproduction instructions

Note: some of my colleagues couldn't reproduce this, but one other person could. It may be browser dependent. I reproduced in Brave and a colleague reproduced in Safari.

  1. Open the site editor, and navigate to a template like 'Blog home'
  2. Click the header template part, and open the block inspector sidebar.
  3. Click 'Edit original' to access the template part editor
  4. When the template part editor opens, sometimes the bug is visible straight away, but sometimes not. If not, the selected inspector tab might have changed to 'Template part', select a block in the template part and ensure the 'Block' tab is selected
  5. From the editor topbar, click the back button
  6. You should now be back in the Template Editor. If the 'Block' tab remained selected then the bug should now be visible. If not, you may need to repeat steps 3-5 a couple of times.

Screenshots, screen recording, code snippet

https://github.com/user-attachments/assets/67ec55c0-e8a5-4

GitHub Labels

[Type] Bug[Package] Components

Want to work on this?

Claim this issue to let others know you're working on it. You'll earn 20 points when you complete it!

Risk Flags

  • browser-dependent behavior
  • potential complexity in implementation
Loading labels...

Details

Points20 pts
Difficultymedium
Scopesomewhat clear
Skill Matchmaybe
Test Focusedno