Fix translations - Avoid registering blocks in the wrong context (#50615)
* Avoid registering block in the wrong context * Add changefile(s) from automation for the following project(s): woocommerce-blocks * Add changefile(s) from automation for the following project(s): woocommerce-blocks --------- Co-authored-by: github-actions <github-actions@github.com>
This commit is contained in:
parent
d04666e35c
commit
381c87da80
|
@ -44,13 +44,14 @@ export const registerBlockSingleProductTemplate = ( {
|
||||||
blockMetadata = blockName;
|
blockMetadata = blockName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const editSiteStore = select( 'core/edit-site' );
|
||||||
|
|
||||||
subscribe( () => {
|
subscribe( () => {
|
||||||
const previousTemplateId = currentTemplateId;
|
const previousTemplateId = currentTemplateId;
|
||||||
const store = select( 'core/edit-site' );
|
|
||||||
|
|
||||||
// With GB 16.3.0 the return type can be a number: https://github.com/WordPress/gutenberg/issues/53230
|
// With GB 16.3.0 the return type can be a number: https://github.com/WordPress/gutenberg/issues/53230
|
||||||
currentTemplateId = parseTemplateId(
|
currentTemplateId = parseTemplateId(
|
||||||
store?.getEditedPostId< string | number | undefined >()
|
editSiteStore?.getEditedPostId< string | number | undefined >()
|
||||||
);
|
);
|
||||||
const hasChangedTemplate = previousTemplateId !== currentTemplateId;
|
const hasChangedTemplate = previousTemplateId !== currentTemplateId;
|
||||||
const hasTemplateId = Boolean( currentTemplateId );
|
const hasTemplateId = Boolean( currentTemplateId );
|
||||||
|
@ -108,7 +109,11 @@ export const registerBlockSingleProductTemplate = ( {
|
||||||
// This subscribe callback could be invoked with the core/blocks store
|
// This subscribe callback could be invoked with the core/blocks store
|
||||||
// which would cause infinite registration loops because of the `registerBlockType` call.
|
// which would cause infinite registration loops because of the `registerBlockType` call.
|
||||||
// This local cache helps prevent that.
|
// This local cache helps prevent that.
|
||||||
if ( ! isBlockRegistered && isAvailableOnPostEditor ) {
|
if (
|
||||||
|
! isBlockRegistered &&
|
||||||
|
isAvailableOnPostEditor &&
|
||||||
|
! editSiteStore
|
||||||
|
) {
|
||||||
if ( isVariationBlock ) {
|
if ( isVariationBlock ) {
|
||||||
blocksRegistered.add( variationName );
|
blocksRegistered.add( variationName );
|
||||||
registerBlockVariation(
|
registerBlockVariation(
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
Significance: minor
|
||||||
|
Type: fix
|
||||||
|
|
||||||
|
Fix translation - Avoid registering blocks in the wrong context.
|
Loading…
Reference in New Issue