[Product Editor] Fix blank editor when clicking Add New while already in editor (#43702)

This commit is contained in:
Matt Sherman 2024-01-16 13:04:48 -05:00 committed by GitHub
parent 8a7ffac49b
commit 3838975b24
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 1 deletions

View File

@ -0,0 +1,5 @@
Significance: patch
Type: fix
Comment: No changelog because this fixes a regression that was introduced in the same release.

View File

@ -158,7 +158,16 @@ export function BlockEditor( {
...settings, ...settings,
productTemplate, productTemplate,
} as Partial< ProductEditorSettings > ); } as Partial< ProductEditorSettings > );
}, [ settings, postType, productTemplate, productType, layoutTemplate ] );
// We don't need to include onChange or updateEditorSettings in the dependencies,
// since we get new instances of them on every render, which would cause an infinite loop.
//
// We include productId in the dependencies to make sure that the effect is run when the
// product is changed, since we need to synchronize the blocks with the template and update
// the blocks by calling onChange.
//
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [ layoutTemplate, settings, productTemplate, productId ] );
// Check if the Modal editor is open from the store. // Check if the Modal editor is open from the store.
const isModalEditorOpen = useSelect( ( select ) => { const isModalEditorOpen = useSelect( ( select ) => {