Enhance Details Block to Separate Summary from Content #59384
Labels
[Block] Details
Affects the Details Block - used to display content which can be shown/hidden
[Type] Enhancement
A suggestion for improvement.
What problem does this address?
There have been a couple threads about the
details
block and its somewhat unintuitive styling: #54549, #57970The problem is that the
<summary>
tag is simply aRichText
control within the block, and the hidden content is contained in theInnerBlocks
. So any top level styles will apply to everything since those styles are applied to the<details>
tag as a whole. The hidden content can be wrapped in agroup
block for styling purposes, but it feels less intuitive for novice users who expect to be able to style thesummary
content separately.What is your proposed solution?
Refactor the block into a container with two child blocks:
core/details-summary
andcore/details-content
that can then be independently styled.In summary, the
core/details
block would be split into:core/details
: Acts like acolumns
block in that it is simply a container for its two child blocks. Would contain one of each ofcore/details-summary
andcore/details-content
in its block template and template lock would be turned on to prevent removing or adding to those child blocks. Would still have its own styling options that apply to all children, along with top-level attributes likeshowContent
to determine if thedetails
element is open on load.core/details-summary
: Acts like acore/heading
block and gets wrapped in the<summary>
tag. Should include theHeadingLevelDropdown
component to optionally wrap the content within the<summary>
tag in a heading tag since that is now valid.core/details-content
: Acts like acore/column
block for easy styling of the hidden content of thedetails
element.The text was updated successfully, but these errors were encountered: