Deprecate single product block save (#51153)

* Add deprecated save

* Fix button styles

* Add changelog

* Add attributes to deprecated prop

* Add supports prop to deprecated obj

* Add code comment
This commit is contained in:
Fernando Marichal 2024-09-11 09:54:43 -03:00 committed by GitHub
parent b728f53f29
commit e4f03589ab
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 39 additions and 1 deletions

View File

@ -0,0 +1,28 @@
/**
* External dependencies
*/
import { InnerBlocks, useBlockProps } from '@wordpress/block-editor';
/**
* Internal dependencies
*/
import metadata from './block.json';
const v1 = {
attributes: metadata.attributes,
supports: metadata.supports,
save: () => {
const blockProps = useBlockProps.save();
return (
<div { ...blockProps }>
{ /* @ts-expect-error: `InnerBlocks.Content` is a component that is typed in WordPress core*/ }
<InnerBlocks.Content />
</div>
);
},
};
const deprecated = [ v1 ];
export default deprecated;

View File

@ -10,10 +10,12 @@ import { BLOCK_ICON } from './constants';
import metadata from './block.json';
import edit from './edit';
import save from './save';
import deprecated from './deprecated';
// @ts-expect-error: `registerBlockType` is a function that is typed in WordPress core.
registerBlockType( metadata, {
icon: BLOCK_ICON,
edit,
save,
deprecated,
} );

View File

@ -4,6 +4,7 @@
import { InnerBlocks, useBlockProps } from '@wordpress/block-editor';
const Save = () => {
// We add the `woocommerce` class to the wrapper to apply WooCommerce styles to the block.
const blockProps = useBlockProps.save( {
className: 'woocommerce',
} );

View File

@ -0,0 +1,4 @@
Significance: minor
Type: fix
Deprecate single product block save #51153

View File

@ -1699,7 +1699,10 @@ p.demo_store,
* Buttons
*/
.woocommerce:where(body:not(.woocommerce-block-theme-has-button-styles)),
:where(body:not(.woocommerce-block-theme-has-button-styles)) .woocommerce {
:where(body:not(.woocommerce-block-theme-has-button-styles)):where(
:not(.edit-post-visual-editor *)
)
.woocommerce {
a.button,
button.button,
input.button,