Skip to content

Commit e3475c8

Browse files
committed
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.
1 parent 7856158 commit e3475c8

7 files changed

Lines changed: 13 additions & 9 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 & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ 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';
1312

1413
/**
1514
* Internal dependencies
@@ -42,14 +41,14 @@ const TABS_TEMPLATE = [
4241
[
4342
'core/tab',
4443
{
45-
label: __( 'Tab' ),
44+
label: 'Tab 1',
4645
},
4746
[ [ 'core/paragraph' ] ],
4847
],
4948
[
5049
'core/tab',
5150
{
52-
label: __( 'Tab' ),
51+
label: 'Tab 2',
5352
},
5453
[ [ 'core/paragraph' ] ],
5554
],
@@ -239,7 +238,7 @@ function Edit( {
239238
const innerBlockProps = useInnerBlocksProps( blockProps, {
240239
__experimentalCaptureToolbars: true,
241240
template: TABS_TEMPLATE,
242-
templateLock: false,
241+
templateLock: 'all',
243242
renderAppender: false,
244243
} );
245244

0 commit comments

Comments
 (0)