Skip to content

Commit 9f5e575

Browse files
t-hamanoscruffianmikachan
authored
Tabs: remove sequential numbering from new tab labels (#77321)
* Tabs: remove sequential numbering from new tab labels New tabs no longer receive auto-incremented "Tab N" labels and placeholders; users set their own titles instead. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * Tabs: use consistent default label for new tabs --------- Co-authored-by: t-hamano <wildworks@git.wordpress.org> Co-authored-by: scruffian <scruffian@git.wordpress.org> Co-authored-by: mikachan <mikachan@git.wordpress.org>
1 parent 433d058 commit 9f5e575

3 files changed

Lines changed: 8 additions & 14 deletions

File tree

packages/block-library/src/tab/add-tab-toolbar-control.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* WordPress dependencies
33
*/
4-
import { sprintf, __ } from '@wordpress/i18n';
4+
import { __ } from '@wordpress/i18n';
55
import { createBlock } from '@wordpress/blocks';
66
import {
77
BlockControls,
@@ -22,13 +22,12 @@ import { useDispatch, useSelect } from '@wordpress/data';
2222
export default function AddTabToolbarControl( { tabsClientId } ) {
2323
const { insertBlock } = useDispatch( blockEditorStore );
2424

25-
const { tabPanelClientId, tabsMenuClientId, tabCount } = useSelect(
25+
const { tabPanelClientId, tabsMenuClientId } = useSelect(
2626
( select ) => {
2727
if ( ! tabsClientId ) {
2828
return {
2929
tabPanelClientId: null,
3030
tabsMenuClientId: null,
31-
tabCount: 0,
3231
};
3332
}
3433
const { getBlocks } = select( blockEditorStore );
@@ -42,7 +41,6 @@ export default function AddTabToolbarControl( { tabsClientId } ) {
4241
return {
4342
tabPanelClientId: tabPanel?.clientId || null,
4443
tabsMenuClientId: tabsMenu?.clientId || null,
45-
tabCount: tabPanel?.innerBlocks?.length || 0,
4644
};
4745
},
4846
[ tabsClientId ]
@@ -54,8 +52,7 @@ export default function AddTabToolbarControl( { tabsClientId } ) {
5452
}
5553

5654
const newTabBlock = createBlock( 'core/tab', {
57-
/* translators: %d: tab number */
58-
label: sprintf( __( 'Tab %d' ), tabCount + 1 ),
55+
label: __( 'Tab' ),
5956
} );
6057
insertBlock( newTabBlock, undefined, tabPanelClientId );
6158

packages/block-library/src/tabs-menu-item/edit.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import clsx from 'clsx';
66
/**
77
* WordPress dependencies
88
*/
9-
import { __, sprintf } from '@wordpress/i18n';
9+
import { __ } from '@wordpress/i18n';
1010
import {
1111
useBlockProps,
1212
store as blockEditorStore,
@@ -138,11 +138,7 @@ function Edit( {
138138
<RichText
139139
tagName="span"
140140
withoutInteractiveFormatting
141-
placeholder={ sprintf(
142-
/* translators: %d is the tab index + 1 */
143-
__( 'Tab title %d' ),
144-
menuItemIndex + 1
145-
) }
141+
placeholder={ __( 'Tab title' ) }
146142
value={ label }
147143
onChange={ handleLabelChange }
148144
/>

packages/block-library/src/tabs/edit.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
} from '@wordpress/block-editor';
1010
import { useSelect, useDispatch } from '@wordpress/data';
1111
import { useMemo, useEffect, useRef } from '@wordpress/element';
12+
import { __ } from '@wordpress/i18n';
1213

1314
/**
1415
* Internal dependencies
@@ -41,14 +42,14 @@ const TABS_TEMPLATE = [
4142
[
4243
'core/tab',
4344
{
44-
label: 'Tab 1',
45+
label: __( 'Tab' ),
4546
},
4647
[ [ 'core/paragraph' ] ],
4748
],
4849
[
4950
'core/tab',
5051
{
51-
label: 'Tab 2',
52+
label: __( 'Tab' ),
5253
},
5354
[ [ 'core/paragraph' ] ],
5455
],

0 commit comments

Comments
 (0)