Skip to content

Commit

Permalink
Merge pull request #364 from material-components/fix/button-invalidation
Browse files Browse the repository at this point in the history
Fix button and image list block invalidation issue
  • Loading branch information
emeaguiar committed Jun 21, 2022
2 parents e86ee71 + 2338be7 commit 43e366d
Show file tree
Hide file tree
Showing 7 changed files with 1,534 additions and 1,540 deletions.
3 changes: 1 addition & 2 deletions plugin/assets/src/block-editor/blocks/button/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,5 @@
"type": "string",
"default": "normal"
}
},
"apiVersion": 2
}
}
4 changes: 1 addition & 3 deletions plugin/assets/src/block-editor/blocks/buttons/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@ const ALLOWED_BLOCKS = [ name ];
const BUTTONS_TEMPLATE = [ [ name ] ];

const Edit = () => {
const blockProps = useBlockProps( {
className: 'wp-block-material-buttons',
} );
const blockProps = useBlockProps();
return (
<div { ...blockProps }>
<InnerBlocks
Expand Down
4 changes: 2 additions & 2 deletions plugin/assets/src/block-editor/blocks/buttons/save.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
/**
* WordPress dependencies
*/
import { InnerBlocks } from '@wordpress/block-editor';
import { InnerBlocks, useBlockProps } from '@wordpress/block-editor';

const Save = () => {
return (
<div>
<div { ...useBlockProps.save() }>
<InnerBlocks.Content />
</div>
);
Expand Down
8 changes: 2 additions & 6 deletions plugin/assets/src/block-editor/blocks/image-list/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,6 @@ const ImageListEdit = ( {
noticeOperations.createErrorNotice( message );
};

const classNames = useBlockProps()?.className;

const galleryProps = {
images: images.map( image => {
image.caption = getCaption( image.id ) || image.caption;
Expand All @@ -252,19 +250,17 @@ const ImageListEdit = ( {
onMove: moveImage,
onSelect: setSelectedImage,
onLinkChange: updateImageLink,
className: classNames,
};

return (
<>
<div { ...useBlockProps() }>
{ 'function' === typeof noticeUI ? noticeUI() : noticeUI }

{ hasImages && <Gallery { ...galleryProps } /> }

<MediaPlaceholder
addToGallery={ hasImagesWithId }
isAppender={ hasImages }
className={ classNames }
disableMediaButtons={ hasImages && ! isSelected }
icon={
! hasImages && (
Expand Down Expand Up @@ -400,7 +396,7 @@ const ImageListEdit = ( {
/>
</PanelBody>
</InspectorControls>
</>
</div>
);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ Object {
"asFragment": [Function],
"baseElement": <body>
<div>
<div
class="wp-block-material-buttons"
>
<div>
<div>
{"id":"button-1","name":"material/button"}
Expand All @@ -17,9 +15,7 @@ Object {
</div>
</body>,
"container": <div>
<div
class="wp-block-material-buttons"
>
<div>
<div>
{"id":"button-1","name":"material/button"}
Expand Down
Loading

0 comments on commit 43e366d

Please sign in to comment.