diff --git a/docs/reference-guides/core-blocks.md b/docs/reference-guides/core-blocks.md
index 820f0afccc2b5..158432cca5c48 100644
--- a/docs/reference-guides/core-blocks.md
+++ b/docs/reference-guides/core-blocks.md
@@ -255,7 +255,7 @@ Hide and show additional content. ([Source](https://github.com/WordPress/gutenbe
- **Name:** core/details
- **Category:** text
- **Supports:** align (full, wide), anchor, color (background, gradients, link, text), interactivity (clientNavigation), layout (~~allowEditing~~), spacing (blockGap, margin, padding), typography (fontSize, lineHeight), ~~html~~
-- **Attributes:** allowedBlocks, showContent, summary
+- **Attributes:** allowedBlocks, name, showContent, summary
## Embed
diff --git a/packages/block-library/src/details/block.json b/packages/block-library/src/details/block.json
index e28d94c03b9aa..e4fadc4a064f9 100644
--- a/packages/block-library/src/details/block.json
+++ b/packages/block-library/src/details/block.json
@@ -17,6 +17,12 @@
"source": "rich-text",
"selector": "summary"
},
+ "name": {
+ "type": "string",
+ "source": "attribute",
+ "attribute": "name",
+ "selector": ".wp-block-details"
+ },
"allowedBlocks": {
"type": "array"
}
diff --git a/packages/block-library/src/details/edit.js b/packages/block-library/src/details/edit.js
index 89aac092df22c..b7e8f815e21c0 100644
--- a/packages/block-library/src/details/edit.js
+++ b/packages/block-library/src/details/edit.js
@@ -8,6 +8,7 @@ import {
InspectorControls,
} from '@wordpress/block-editor';
import {
+ TextControl,
ToggleControl,
__experimentalToolsPanel as ToolsPanel,
__experimentalToolsPanelItem as ToolsPanelItem,
@@ -30,7 +31,7 @@ const TEMPLATE = [
];
function DetailsEdit( { attributes, setAttributes } ) {
- const { showContent, summary, allowedBlocks } = attributes;
+ const { name, showContent, summary, allowedBlocks } = attributes;
const blockProps = useBlockProps();
const innerBlocksProps = useInnerBlocksProps( blockProps, {
template: TEMPLATE,
@@ -75,6 +76,20 @@ function DetailsEdit( { attributes, setAttributes } ) {
+
+
+ setAttributes( { name: newName } )
+ }
+ help={ __(
+ 'Enables multiple Details blocks with the same name attribute to be connected, with only one open at a time.'
+ ) }
+ />
+
{
diff --git a/packages/block-library/src/details/save.js b/packages/block-library/src/details/save.js
index 0df5f63ce9410..c7594d4d5aa3f 100644
--- a/packages/block-library/src/details/save.js
+++ b/packages/block-library/src/details/save.js
@@ -4,12 +4,16 @@
import { RichText, useBlockProps, InnerBlocks } from '@wordpress/block-editor';
export default function save( { attributes } ) {
- const { showContent } = attributes;
+ const { name, showContent } = attributes;
const summary = attributes.summary ? attributes.summary : 'Details';
const blockProps = useBlockProps.save();
return (
-
+