diff --git a/packages/block-library/src/tab/edit.js b/packages/block-library/src/tab/edit.js index 720e7c48a12cc8..b9f923872a3f3b 100644 --- a/packages/block-library/src/tab/edit.js +++ b/packages/block-library/src/tab/edit.js @@ -42,9 +42,7 @@ export default function Edit( { attributes, clientId, setAttributes } ) { } }, [ label, setAttributes, tabIndex ] ); - const blockProps = useBlockProps( { - className: isActive ? 'is-active' : '', - } ); + const blockProps = useBlockProps(); const innerBlocksProps = useInnerBlocksProps( blockProps, { renderAppender: hasChildBlocks ? undefined @@ -54,6 +52,7 @@ export default function Edit( { attributes, clientId, setAttributes } ) {
diff --git a/packages/block-library/src/tab/save.js b/packages/block-library/src/tab/save.js index dca2d2856dbed3..3f2146a2ef1280 100644 --- a/packages/block-library/src/tab/save.js +++ b/packages/block-library/src/tab/save.js @@ -4,23 +4,12 @@ import { useBlockProps, useInnerBlocksProps } from '@wordpress/block-editor'; export default function save( { attributes } ) { - const { anchor, slug, tabIndex } = attributes; + const { anchor, slug } = attributes; const tabPanelId = anchor || slug; - const tabLabelId = tabPanelId + '--tab'; // The first tab in the set is always active on initial load. - const blockProps = useBlockProps.save( { - className: tabIndex === 0 ? 'is-active' : '', - } ); + const blockProps = useBlockProps.save(); const innerBlocksProps = useInnerBlocksProps.save( blockProps ); - return ( - - ); + return ; } diff --git a/packages/block-library/src/tab/style.scss b/packages/block-library/src/tab/style.scss index e96d32fb7e6bd3..1d92981230b173 100644 --- a/packages/block-library/src/tab/style.scss +++ b/packages/block-library/src/tab/style.scss @@ -1,13 +1,7 @@ .wp-block-tab { - display: none; padding: 1em 0; - &.is-active { - display: block; - } - > *:first-child { margin-top: 0; } } - diff --git a/packages/block-library/src/tabs/block.json b/packages/block-library/src/tabs/block.json index 49598ad5521195..96ccd1404d3e7d 100644 --- a/packages/block-library/src/tabs/block.json +++ b/packages/block-library/src/tabs/block.json @@ -15,10 +15,10 @@ "source": "query", "selector": ".wp-block-tabs__tab-label", "query": { - "id": { + "href": { "type": "string", "source": "attribute", - "attribute": "aria-controls" + "attribute": "href" }, "label": { "type": "string", diff --git a/packages/block-library/src/tabs/edit.js b/packages/block-library/src/tabs/edit.js index d52cbb93a61802..bc4476dc6152f4 100644 --- a/packages/block-library/src/tabs/edit.js +++ b/packages/block-library/src/tabs/edit.js @@ -1,8 +1,3 @@ -/** - * External dependencies - */ -import clsx from 'clsx'; - /** * WordPress dependencies */ @@ -117,7 +112,8 @@ export default function Edit( { clientId, setAttributes } ) { setAttributes( { innerTabs: innerTabBlocks.map( ( block ) => ( { label: block.attributes.label, - id: block.attributes.anchor || block.attributes.slug, + href: + '#' + ( block.attributes.anchor || block.attributes.slug ), } ) ), } ); @@ -134,7 +130,7 @@ export default function Edit( { clientId, setAttributes } ) { updateBlockAttributes, ] ); - const blockProps = useBlockProps(); + const blockProps = useBlockProps( { className: 'interactive' } ); const innerBlockProps = useInnerBlocksProps( { className: 'wp-block-tabs__content', @@ -165,14 +161,12 @@ export default function Edit( { clientId, setAttributes } ) { setActiveTab( block.clientId ) } role="tab" - tab-index={ tabIndexAttr } + tabIndex={ tabIndexAttr } >