Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/reference-guides/core-blocks.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Displays a section of content in an accordion, including a header and expandable
- **Category:** design
- **Parent:** core/accordion
- **Allowed Blocks:** core/accordion-header, core/accordion-panel
- **Supports:** color (background, gradient, text), interactivity, shadow, spacing (blockGap, margin)
- **Supports:** color (background, gradient, text), interactivity, layout, shadow, spacing (blockGap, margin)
- **Attributes:** openByDefault

## Accordion Header
Expand All @@ -50,7 +50,7 @@ Displays an accordion panel. ([Source](https://github.com/WordPress/gutenberg/tr
- **Experimental:** true
- **Category:** design
- **Parent:** core/accordion-content
- **Supports:** color (background, gradient, text), interactivity, shadow, spacing (blockGap, margin, padding), typography (fontSize, lineHeight)
- **Supports:** color (background, gradient, text), interactivity, layout, shadow, spacing (blockGap, margin, padding), typography (fontSize, lineHeight)
- **Attributes:** allowedBlocks, isSelected, openByDefault, templateLock

## Archives
Expand Down
3 changes: 2 additions & 1 deletion packages/block-library/src/accordion-content/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
"width": true
}
},
"shadow": true
"shadow": true,
"layout": true
},
"attributes": {
"openByDefault": {
Expand Down
48 changes: 21 additions & 27 deletions packages/block-library/src/accordion-content/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,8 @@ import clsx from 'clsx';
*/
import { useToolsPanelDropdownMenuProps } from '../utils/hooks';

export default function Edit( {
attributes: { openByDefault },
clientId,
setAttributes,
} ) {
export default function Edit( { attributes, clientId, setAttributes } ) {
const { openByDefault } = attributes;
const dropdownMenuProps = useToolsPanelDropdownMenuProps();

const { isSelected, getBlockOrder } = useSelect(
Expand Down Expand Up @@ -67,29 +64,26 @@ export default function Edit( {
updateBlockAttributes,
] );

const blockProps = useBlockProps();
const innerBlocksProps = useInnerBlocksProps(
{
...blockProps,
className: clsx( blockProps.className, {
'is-open': openByDefault || isSelected,
} ),
},
{
template: [
[ 'core/accordion-header', {} ],
[
'core/accordion-panel',
{
openByDefault,
},
],
const blockProps = useBlockProps( {
className: clsx( {
'is-open': openByDefault || isSelected,
} ),
} );

const innerBlocksProps = useInnerBlocksProps( blockProps, {
template: [
[ 'core/accordion-header', {} ],
[
'core/accordion-panel',
{
openByDefault,
},
],
templateLock: 'all',
directInsert: true,
templateInsertUpdatesSelection: true,
}
);
],
templateLock: 'all',
directInsert: true,
templateInsertUpdatesSelection: true,
} );

return (
<>
Expand Down
3 changes: 2 additions & 1 deletion packages/block-library/src/accordion-panel/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@
"fontSize": true
}
},
"shadow": true
"shadow": true,
"layout": true
},
"attributes": {
"allowedBlocks": {
Expand Down
12 changes: 6 additions & 6 deletions packages/block-library/src/accordion/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,6 @@
}
}

.accordion-content__heading {
margin-block-start: 0;
margin-block-end: 0;
}

.accordion-content__toggle {
font-family: inherit;
font-size: inherit;
Expand Down Expand Up @@ -48,7 +43,12 @@
.is-layout-flow > .wp-block-accordion-panel,
.wp-block-accordion-panel {
overflow: hidden;
margin: 0;
}

// Prevent blockGap from Accordion Content block from adding extra margin between accordions.
.wp-block-accordion-panel[inert],
.wp-block-accordion-panel[aria-hidden="true"] {
margin-block-start: 0;
}

.accordion-panel__wrapper {
Expand Down
Loading