Skip to content

Commit

Permalink
Details block: Add placeholder attribute (WordPress#68917)
Browse files Browse the repository at this point in the history
Co-authored-by: shimotmk <[email protected]>
Co-authored-by: Mamaduka <[email protected]>
  • Loading branch information
3 people authored Jan 29, 2025
1 parent 41deebd commit ed64574
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion docs/reference-guides/core-blocks.md
Original file line number Diff line number Diff line change
Expand Up @@ -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, name, showContent, summary
- **Attributes:** allowedBlocks, name, placeholder, showContent, summary

## Embed

Expand Down
3 changes: 3 additions & 0 deletions packages/block-library/src/details/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
},
"allowedBlocks": {
"type": "array"
},
"placeholder": {
"type": "string"
}
},
"supports": {
Expand Down
5 changes: 3 additions & 2 deletions packages/block-library/src/details/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ const TEMPLATE = [
];

function DetailsEdit( { attributes, setAttributes } ) {
const { name, showContent, summary, allowedBlocks } = attributes;
const { name, showContent, summary, allowedBlocks, placeholder } =
attributes;
const blockProps = useBlockProps();
const innerBlocksProps = useInnerBlocksProps( blockProps, {
template: TEMPLATE,
Expand Down Expand Up @@ -100,7 +101,7 @@ function DetailsEdit( { attributes, setAttributes } ) {
<RichText
identifier="summary"
aria-label={ __( 'Write summary' ) }
placeholder={ __( 'Write summary…' ) }
placeholder={ placeholder || __( 'Write summary…' ) }
allowedFormats={ [] }
withoutInteractiveFormatting
value={ summary }
Expand Down

0 comments on commit ed64574

Please sign in to comment.