Skip to content

Commit 810d933

Browse files
t-hamanomikachan
andauthored
Accordion Header: Don't use flex-direction:reverse (#71737)
Co-authored-by: t-hamano <[email protected]> Co-authored-by: mikachan <[email protected]>
1 parent d6210ac commit 810d933

File tree

5 files changed

+19
-28
lines changed

5 files changed

+19
-28
lines changed

packages/block-library/src/accordion-header/block.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
"title": {
6464
"type": "rich-text",
6565
"source": "rich-text",
66-
"selector": "span",
66+
"selector": ".accordion-content__toggle-title",
6767
"role": "content"
6868
},
6969
"level": {

packages/block-library/src/accordion-header/edit.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ export default function Edit( { attributes, setAttributes, context } ) {
6565
'accordion-content__heading',
6666
{
6767
[ `has-custom-font-size` ]: blockProps.style.fontSize,
68-
[ `icon-position-left` ]: iconPosition === 'left',
6968
[ `has-text-align-${ textAlign }` ]: textAlign,
7069
}
7170
) }
@@ -81,6 +80,11 @@ export default function Edit( { attributes, setAttributes, context } ) {
8180
...spacingProps.style,
8281
} }
8382
>
83+
{ showIcon && iconPosition === 'left' && (
84+
<span className="accordion-content__toggle-icon">
85+
+
86+
</span>
87+
) }
8488
<RichText
8589
withoutInteractiveFormatting
8690
disableLineBreaks
@@ -91,7 +95,7 @@ export default function Edit( { attributes, setAttributes, context } ) {
9195
}
9296
placeholder={ __( 'Accordion title' ) }
9397
/>
94-
{ showIcon && (
98+
{ showIcon && iconPosition === 'right' && (
9599
<span className="accordion-content__toggle-icon">
96100
+
97101
</span>

packages/block-library/src/accordion-header/save.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ export default function save( { attributes } ) {
3434
'accordion-content__heading',
3535
{
3636
[ `has-custom-font-size` ]: blockProps?.style?.fontSize,
37-
[ `icon-position-left` ]: iconPosition === 'left',
3837
[ `has-text-align-${ textAlign }` ]: textAlign,
3938
}
4039
) }
@@ -50,8 +49,15 @@ export default function save( { attributes } ) {
5049
...spacingProps.style,
5150
} }
5251
>
53-
<RichText.Content tagName="span" value={ title } />
54-
{ showIcon && (
52+
{ showIcon && iconPosition === 'left' && (
53+
<span className="accordion-content__toggle-icon">+</span>
54+
) }
55+
<RichText.Content
56+
className="accordion-content__toggle-title"
57+
tagName="span"
58+
value={ title }
59+
/>
60+
{ showIcon && iconPosition === 'right' && (
5561
<span className="accordion-content__toggle-icon">+</span>
5662
) }
5763
</button>
Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,9 @@
1-
/**
2-
* External dependencies
3-
*/
4-
import clsx from 'clsx';
51
/**
62
* WordPress dependencies
73
*/
84
import { useBlockProps, useInnerBlocksProps } from '@wordpress/block-editor';
95

10-
export default function save( { attributes } ) {
11-
const { iconPosition } = attributes;
6+
export default function save() {
127
const blockProps = useBlockProps.save();
13-
const className = clsx(
14-
{
15-
'icon-position-left': iconPosition === 'left',
16-
},
17-
blockProps.className
18-
);
19-
20-
return (
21-
<div { ...useInnerBlocksProps.save( { ...blockProps, className } ) } />
22-
);
8+
return <div { ...useInnerBlocksProps.save( blockProps ) } />;
239
}

packages/block-library/src/accordion/style.scss

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
width: 100%;
3737
}
3838

39-
.accordion-content__toggle > span:not(.accordion-content__toggle-icon) {
39+
.accordion-content__toggle-title {
4040
flex: 1;
4141
}
4242

@@ -68,11 +68,6 @@
6868
background-color: unset;
6969
}
7070

71-
.wp-block-accordion-header.icon-position-left .accordion-content__toggle {
72-
/* stylelint-disable-next-line declaration-property-value-allowed-list -- This should be refactored to not use the row-reverse value. */
73-
flex-direction: row-reverse;
74-
}
75-
7671
.accordion-content__toggle:focus-visible {
7772
outline: 2px solid -webkit-focus-ring-color;
7873
outline-offset: 2px;

0 commit comments

Comments
 (0)