Commit ac41afb13c for woocommerce
commit ac41afb13ca8e070b2684ca2f1c502a3e9e3e6cc
Author: Rostislav Wolný <1082140+costasovo@users.noreply.github.com>
Date: Wed Jan 28 11:53:57 2026 +0100
Email Editor: Fix email template selection modal becomes unresponsive with Gutenberg v22 (#63000)
* Fix fetching the template after it was freshly selected
The key change is using getEditedEntityRecord when fetching the edited post
from the store. The getEntityRecord was returning a value without
the template.
* Add change log
diff --git a/packages/js/email-editor/changelog/wooprd-1780-email-template-selection-modal-becomes-unresponsive b/packages/js/email-editor/changelog/wooprd-1780-email-template-selection-modal-becomes-unresponsive
new file mode 100644
index 0000000000..e4f5bc0e0c
--- /dev/null
+++ b/packages/js/email-editor/changelog/wooprd-1780-email-template-selection-modal-becomes-unresponsive
@@ -0,0 +1,4 @@
+Significance: patch
+Type: fix
+
+Fix infinite loop when selecting a template in the email design selector modal
diff --git a/packages/js/email-editor/src/components/block-editor/editor.tsx b/packages/js/email-editor/src/components/block-editor/editor.tsx
index 4bd889b1c8..f84bef8655 100644
--- a/packages/js/email-editor/src/components/block-editor/editor.tsx
+++ b/packages/js/email-editor/src/components/block-editor/editor.tsx
@@ -60,19 +60,31 @@ export function InnerEditor( {
const { post, template } = useSelect(
( select ) => {
- const { getEntityRecord } = select( coreStore );
- const { getEditedPostTemplate } = select( storeName );
- const postObject = getEntityRecord(
+ const { getEditedEntityRecord } = select( coreStore );
+ const editedPost = getEditedEntityRecord(
'postType',
currentPost.postType,
currentPost.postId
- ) as Post | null;
+ );
+
+ // getEditedEntityRecord can return false/undefined if not found
+ if ( ! editedPost || typeof editedPost === 'boolean' ) {
+ return { post: null, template: null };
+ }
+
+ const postData = editedPost as unknown as Post;
+
+ // Get template for non-template post types
+ if ( currentPost.postType === 'wp_template' ) {
+ return { post: postData, template: null };
+ }
+
+ const { getEditedPostTemplate } = select( storeName );
+ const templateData = getEditedPostTemplate( postData.template );
+
return {
- template:
- postObject && currentPost.postType !== 'wp_template'
- ? getEditedPostTemplate( postObject.template )
- : null,
- post: postObject,
+ post: postData,
+ template: templateData,
};
},
[ currentPost.postType, currentPost.postId ]