Skip to content

Commit e0a171a

Browse files
t-hamanomikachan
andauthored
Tabs: Lock top-level structure and disable visibility controls (#77370)
* Tabs: Lock top-level structure and disable visibility controls Prevent users from removing or reordering the tabs menu and panels by locking the parent Tabs template, and hide the visibility panel on tab blocks where per-block hiding is not meaningful. Inner menu items remain editable so tabs can still be added or rearranged. * Tabs: Remove redundant `lock` attributes from TABS_TEMPLATE The parent `useInnerBlocksProps` already sets `templateLock: 'all'`, which cascades to descendants and prevents removal/insertion/move. The per-child `lock: { remove: true }` entries were therefore no-ops. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> --------- Co-authored-by: t-hamano <wildworks@git.wordpress.org> Co-authored-by: mikachan <mikachan@git.wordpress.org>
1 parent 5070468 commit e0a171a

7 files changed

Lines changed: 13 additions & 16 deletions

File tree

docs/reference-guides/core-blocks.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -996,7 +996,7 @@ Content for a tab in a tabbed interface. ([Source](https://github.com/WordPress/
996996
- **Experimental:** true
997997
- **Category:** design
998998
- **Parent:** core/tab-panel
999-
- **Supports:** anchor, color (background, text), layout, renaming, spacing (blockGap, padding, ~~margin~~), typography (fontSize), ~~html~~, ~~reusable~~
999+
- **Supports:** anchor, color (background, text), layout, renaming, spacing (blockGap, padding, ~~margin~~), typography (fontSize), ~~html~~, ~~reusable~~, ~~visibility~~
10001000
- **Attributes:** label
10011001

10021002
## Tab Panel
@@ -1008,7 +1008,7 @@ Container for tab panel content in a tabbed interface. ([Source](https://github.
10081008
- **Category:** design
10091009
- **Parent:** core/tabs
10101010
- **Allowed Blocks:** core/tab
1011-
- **Supports:** color (background, heading, link, text), dimensions (~~aspectRatio~~, ~~height~~, ~~minHeight~~, ~~width~~), layout (allowJustification, default, ~~allowOrientation~~, ~~allowSizingOnChildren~~, ~~allowSwitching~~, ~~allowVerticalAlignment~~), spacing (margin, padding, ~~blockGap~~), typography (fontSize), ~~anchor~~, ~~html~~, ~~lock~~, ~~reusable~~
1011+
- **Supports:** color (background, heading, link, text), dimensions (~~aspectRatio~~, ~~height~~, ~~minHeight~~, ~~width~~), layout (allowJustification, default, ~~allowOrientation~~, ~~allowSizingOnChildren~~, ~~allowSwitching~~, ~~allowVerticalAlignment~~), spacing (margin, padding, ~~blockGap~~), typography (fontSize), ~~anchor~~, ~~html~~, ~~lock~~, ~~reusable~~, ~~visibility~~
10121012

10131013
## Table
10141014

@@ -1049,7 +1049,7 @@ Display the tab buttons for a tabbed interface. ([Source](https://github.com/Wor
10491049
- **Category:** design
10501050
- **Parent:** core/tabs
10511051
- **Allowed Blocks:** core/tabs-menu-item
1052-
- **Supports:** color (background, text), dimensions (~~aspectRatio~~, ~~height~~, ~~minHeight~~, ~~width~~), layout (allowJustification, allowOrientation, allowVerticalAlignment, default, ~~allowSwitching~~), spacing (blockGap, margin, padding), typography (fontSize), ~~html~~, ~~lock~~, ~~reusable~~
1052+
- **Supports:** color (background, text), dimensions (~~aspectRatio~~, ~~height~~, ~~minHeight~~, ~~width~~), layout (allowJustification, allowOrientation, allowVerticalAlignment, default, ~~allowSwitching~~), spacing (blockGap, margin, padding), typography (fontSize), ~~html~~, ~~lock~~, ~~reusable~~, ~~visibility~~
10531053

10541054
## Tab Menu Item
10551055

@@ -1059,7 +1059,7 @@ A single tab button in the tabs menu. ([Source](https://github.com/WordPress/gut
10591059
- **Experimental:** true
10601060
- **Category:** design
10611061
- **Parent:** core/tabs-menu
1062-
- **Supports:** color (background, text), layout (~~allowEditing~~), spacing (padding), typography (fontSize, textAlign), ~~html~~, ~~lock~~, ~~reusable~~
1062+
- **Supports:** color (background, text), layout (~~allowEditing~~), spacing (padding), typography (fontSize, textAlign), ~~html~~, ~~lock~~, ~~reusable~~, ~~visibility~~
10631063

10641064
## Tag Cloud
10651065

packages/block-library/src/tab-panel/block.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"anchor": false,
1616
"html": false,
1717
"reusable": false,
18+
"visibility": false,
1819
"lock": false,
1920
"dimensions": {
2021
"aspectRatio": false,

packages/block-library/src/tab/block.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@
4646
"__experimentalFontFamily": true
4747
}
4848
},
49-
"renaming": true
49+
"renaming": true,
50+
"visibility": false
5051
},
5152
"providesContext": {
5253
"core/tab-label": "label"

packages/block-library/src/tabs-menu-item/block.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
"supports": {
2121
"html": false,
2222
"reusable": false,
23+
"visibility": false,
2324
"lock": false,
2425
"color": {
2526
"background": true,

packages/block-library/src/tabs-menu/block.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"supports": {
1616
"html": false,
1717
"reusable": false,
18+
"visibility": false,
1819
"lock": false,
1920
"dimensions": {
2021
"aspectRatio": false,

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ function Edit( { clientId, __unstableLayoutClassNames: layoutClassNames } ) {
3636
const innerBlocksProps = useInnerBlocksProps( blockProps, {
3737
allowedBlocks: [ 'core/tabs-menu-item' ],
3838
orientation: 'horizontal',
39+
templateLock: false,
3940
renderAppender: false,
4041
} );
4142

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

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,23 +21,15 @@ const EMPTY_ARRAY = [];
2121
const TABS_TEMPLATE = [
2222
[
2323
'core/tabs-menu',
24-
{
25-
lock: {
26-
remove: true,
27-
},
28-
},
24+
{},
2925
[
3026
[ 'core/tabs-menu-item', {} ],
3127
[ 'core/tabs-menu-item', {} ],
3228
],
3329
],
3430
[
3531
'core/tab-panel',
36-
{
37-
lock: {
38-
remove: true,
39-
},
40-
},
32+
{},
4133
[
4234
[
4335
'core/tab',
@@ -239,7 +231,7 @@ function Edit( {
239231
const innerBlockProps = useInnerBlocksProps( blockProps, {
240232
__experimentalCaptureToolbars: true,
241233
template: TABS_TEMPLATE,
242-
templateLock: false,
234+
templateLock: 'all',
243235
renderAppender: false,
244236
} );
245237

0 commit comments

Comments
 (0)