Fix: Tabs block: Start with empty tab labels with placeholders - #81009
Conversation
|
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 If 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. |
t-hamano
left a comment
There was a problem hiding this comment.
Thanks for the PR.
I agree with starting from an empty tab label, but I'm not sure if customizable placeholders are really needed. For now, I think we should focus only on starting with an empty tab label in this PR and backport it to 7.1. What do you think?
Another point is that we need to clarify whether empty tab labels should apply not only when adding a new tab but also when inserting a block.
I guess it would be fine, we can create an enhancement ticket for customizable placeholder and limit this to only start with empty label if we need to ship to 7.1. Based on overall descision, I would remove it from PR and update the PR description as well.
Can you clarify on this, I see after the testing, When adding the tabs block the labels are not added, instead placeholders are there, and also when adding a tab, the placeholder is added. Thanks, |
This PR currently works like this. insert-without-default-label.mp4I thought it was supposed to work like this. insert-with-default-label.mp4I don't have a strong opinion on which approach is better, but after looking at this PR, I'm starting to think that always adding an empty label might make more sense. |
A customizable placeholder is currently not highest priority, but it'd be a good enhancement nonetheless. I'd probably change the "tab title" placeholder in some of my patterns to "Feature title" oder "Number".
Always empty is good IMO. Everyone will change the prefilled “Tab” text anyway, so we might as well leave it empty from the start. |
|
So, let's adopt an approach that starts from empty. Shall we remove the customizable placeholder attributes for now and backport this PR to 7.1? |
There was a problem hiding this comment.
Looks good from my end.
@Mamaduka @hanneslsm, What are your thoughts on backporting this to 7.1?
Update: I noticed the 👍 in #81009 (comment). Let's backport it to 7.1.
|
There was a conflict while trying to cherry-pick the commit to the wp/7.1 branch. Please resolve the conflict manually and create a PR to the wp/7.1 branch. PRs to wp/7.1 are similar to PRs to trunk, but you should base your PR on the wp/7.1 branch instead of trunk. |
|
@hbhalodia, do you have the bandwidth to manually backport this PR to 7.1? It should likely only involve resolving changelog file conflicts 👍 |
New tabs no longer get a default 'Tab' label (#81009), so the assertion after pressing Enter at the end of a label expects an empty label. Co-Authored-By: Claude <noreply@anthropic.com>
These four files were committed by mistake while preparing the manual backport. They are not part of WordPress#81009 and are not tracked in trunk or wp/7.1. Co-Authored-By: Claude <noreply@anthropic.com>
* Fix: Tabs block: Start with empty tab labels with placeholders (#81009) * Add placeholder instead of tabs label * Update block docs and add changelog entry * Updated tests and asserts placeholder check to existing tests * Remove placeholder attribute * Remove extra spacing * Remove extra line Co-authored-by: hbhalodia <hbhalodia@git.wordpress.org> Co-authored-by: t-hamano <wildworks@git.wordpress.org> Co-authored-by: Mamaduka <mamaduka@git.wordpress.org> Co-authored-by: hanneslsm <hanneslsm@git.wordpress.org> Co-authored-by: tyxla <tyxla@git.wordpress.org> * Remove unrelated .claude/skills files from the backport These four files were committed by mistake while preparing the manual backport. They are not part of #81009 and are not tracked in trunk or wp/7.1. Co-Authored-By: Claude <noreply@anthropic.com> --------- Co-authored-by: hbhalodia <hbhalodia@git.wordpress.org> Co-authored-by: t-hamano <wildworks@git.wordpress.org> Co-authored-by: Mamaduka <mamaduka@git.wordpress.org> Co-authored-by: hanneslsm <hanneslsm@git.wordpress.org> Co-authored-by: tyxla <tyxla@git.wordpress.org> Co-authored-by: Aki Hamano <tetsuaki.hamano@gmail.com> Co-authored-by: Claude <noreply@anthropic.com>
…lders (#81429) * Fix: Tabs block: Start with empty tab labels with placeholders (#81009) * Add placeholder instead of tabs label * Update block docs and add changelog entry * Updated tests and asserts placeholder check to existing tests * Remove placeholder attribute * Remove extra spacing * Remove extra line Co-authored-by: hbhalodia <hbhalodia@git.wordpress.org> Co-authored-by: t-hamano <wildworks@git.wordpress.org> Co-authored-by: Mamaduka <mamaduka@git.wordpress.org> Co-authored-by: hanneslsm <hanneslsm@git.wordpress.org> Co-authored-by: tyxla <tyxla@git.wordpress.org> * Remove unrelated .claude/skills files from the backport These four files were committed by mistake while preparing the manual backport. They are not part of #81009 and are not tracked in trunk or wp/7.1. Co-Authored-By: Claude <noreply@anthropic.com> * Update label and template as per new changes * Remove extra changelog entryi * Update changelog entry --------- Co-authored-by: hbhalodia <hbhalodia@git.wordpress.org> Co-authored-by: t-hamano <wildworks@git.wordpress.org> Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>
* Add placeholder instead of tabs label * Update block docs and add changelog entry * Updated tests and asserts placeholder check to existing tests * Remove placeholder attribute * Remove extra spacing * Remove extra line Co-authored-by: hbhalodia <hbhalodia@git.wordpress.org> Co-authored-by: t-hamano <wildworks@git.wordpress.org> Co-authored-by: Mamaduka <mamaduka@git.wordpress.org> Co-authored-by: hanneslsm <hanneslsm@git.wordpress.org> Co-authored-by: tyxla <tyxla@git.wordpress.org>
…lders (#81429) * Fix: Tabs block: Start with empty tab labels with placeholders (#81009) * Add placeholder instead of tabs label * Update block docs and add changelog entry * Updated tests and asserts placeholder check to existing tests * Remove placeholder attribute * Remove extra spacing * Remove extra line Co-authored-by: hbhalodia <hbhalodia@git.wordpress.org> Co-authored-by: t-hamano <wildworks@git.wordpress.org> Co-authored-by: Mamaduka <mamaduka@git.wordpress.org> Co-authored-by: hanneslsm <hanneslsm@git.wordpress.org> Co-authored-by: tyxla <tyxla@git.wordpress.org> * Remove unrelated .claude/skills files from the backport These four files were committed by mistake while preparing the manual backport. They are not part of #81009 and are not tracked in trunk or wp/7.1. Co-Authored-By: Claude <noreply@anthropic.com> * Update label and template as per new changes * Remove extra changelog entryi * Update changelog entry --------- Co-authored-by: hbhalodia <hbhalodia@git.wordpress.org> Co-authored-by: t-hamano <wildworks@git.wordpress.org> Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>
What?
Closes #80957
Why?
How?
Testing Instructions
Tab Titleinstead ofTablabel.placeholderattribute and use that pattern, you would notice the placeholder is what you have added for pattern.Testing Instructions for Keyboard
Use of AI Tools
AI Summary
What?
Closes #80957
Tabs now start out untitled. Instead of inserting two tabs literally labelled "Tab", the Tabs block inserts two tabs with an empty
labelthat render a "Tab title" placeholder in the editor.core/tab-panelalso gains an optionalplaceholderattribute so patterns and templates can replace that prompt with something contextual, e.g. "Ingredient group" or "Question".Why?
The hardcoded
__( 'Tab' )default meant every new tab arrived pre-filled with a word nobody wants to keep:The Tab List block already had a
__( 'Tab title' )placeholder in place — it was simply never visible, because the label was never empty. This change lets that placeholder do its job, and adds the pattern-level override suggested in the issue.How?
packages/block-library/src/tab-panels/edit.js[ [ 'core/tab-panel' ], [ 'core/tab-panel' ] ]— thelabel: __( 'Tab' )defaults are gonepackages/block-library/src/tabs/use-tab-actions.jsinsertTabcreatescore/tab-panelwith no attributes, so tabs added via the toolbar or Enter are also untitledpackages/block-library/src/tab-panel/block.jsonplaceholderstring attributepackages/block-library/src/tab-list/edit.jsRichTextuses its panel'splaceholder, falling back to__( 'Tab title' )packages/block-library/src/tab-panel/README.mdnpm run docs:blocks-detailpackages/block-library/CHANGELOG.mdtest/e2e/specs/editor/blocks/tabs.spec.jsTab labelsdescribe block, 3 testsImplementation notes:
placeholderattribute lives oncore/tab-panel, next tolabel. The label is a tab-panel attribute that Tab List renders on its behalf, so its placeholder belongs in the same place. This matches the existingplaceholderattribute convention in Paragraph, Heading, List Item, Details, and Post Title.tab-list/save.jspasses no placeholder toRichText.Content, so nothing is added to the saved markup or the front end.core/tab-paneldeclares its own prompt; a tab the author adds afterwards falls back to"Tab title". Making added tabs inherit a sibling's prompt would need the attribute to move up tocore/tabs/core/tab-listand reach the labels through block context — deliberately out of scope here.labelalready defaulted to""; only the values written at insertion time changed. Existing posts parse and serialize byte-for-byte identically, andplaceholderhas no default, so it is absent from markup unless a pattern sets it.Testing Instructions
Create a new post and insert a Tabs block.
Both tabs are empty and show a greyed-out "Tab title" prompt. Open the code editor (Ctrl+Shift+Alt+M) and confirm the tab panels carry no
labelattribute.Click the first tab and type a title. The placeholder disappears on that tab only; the second tab still prompts.
With a tab selected, click Add tab in the block toolbar. The new tab is empty and shows the prompt. Same when pressing Enter at the end of an existing tab label.
Confirm no regression on existing content: paste the markup below into the code editor, switch back to the visual editor, and check the tabs still read "Tab 1" / "Tab 2" with no block validation warning.
Publish a post with untitled tabs and view the front end. The tab buttons render empty — expected, and the same as publishing an empty Heading. Tab switching still works.
Testing the
placeholderoverrideA. Quickest check — no PHP required
Expected: the first tab prompts "Ingredient group", the second "Cooking step" — placeholders are per panel and can differ. Typing in either replaces only that tab's prompt. Add a third tab from the toolbar and it falls back to "Tab title".
B. Testing from a pattern
As a theme pattern — drop this in the active block theme as
patterns/tabs-placeholder-test.php:Or as a plugin — drop this in
wp-content/mu-plugins/tabs-placeholder-test.php(single-quoted heredoc keeps the markup verbatim):Steps: open the inserter → Patterns → Featured → insert "Placeholder test tabs".
Expected: both tabs prompt "Ingredient group" instead of "Tab title". The pattern preview in the inserter shows the prompts too. Nothing appears in the saved markup for the placeholder beyond the attribute itself, and the front end renders empty buttons until the author types.
Keep the two empty
<button type="button" role="tab"></button>elements in the Tab List markup — that saved markup is what the front end renders, anduseTabListItemsSyncrefills it from the panel labels once the author types.C. Testing from a block template
Post type template —
wp-content/mu-plugins/tabs-template-test.php:Steps: go to Placeholder tests → Add New.
Expected: the Tabs block is pre-inserted with two tabs prompting "Question".
JS equivalent for a custom block's
InnerBlockstemplate or a block variation:Testing Instructions for Keyboard
/tabsthen Enter).RichTextfalls back to the placeholder for the editable'saria-labelwhen no explicit label is set, so an untitled tab announces "Tab title" (or the pattern's custom prompt) rather than nothing.Automated tests
The new
Tab labelsdescribe block covers:placeholderattribute overrides the prompt,