From 292b7daf605a6f0a8065a4b4c0f30ff678639998 Mon Sep 17 00:00:00 2001 From: Mario Santos Date: Fri, 17 May 2024 12:39:51 +0200 Subject: [PATCH] Add fallback for postId --- packages/editor/src/bindings/post-meta.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/packages/editor/src/bindings/post-meta.js b/packages/editor/src/bindings/post-meta.js index 28931acb899908..b6cf0f2d3c2ae0 100644 --- a/packages/editor/src/bindings/post-meta.js +++ b/packages/editor/src/bindings/post-meta.js @@ -16,22 +16,29 @@ export default { return args.key; }, getValue( { registry, context, args } ) { + const postId = context.postId + ? context.postId + : registry.select( editorStore ).getCurrentPostId(); const postType = context.postType ? context.postType : registry.select( editorStore ).getCurrentPostType(); return registry .select( coreDataStore ) - .getEditedEntityRecord( 'postType', postType, context.postId ) - .meta?.[ args.key ]; + .getEditedEntityRecord( 'postType', postType, postId ).meta?.[ + args.key + ]; }, setValue( { registry, context, args, value } ) { + const postId = context.postId + ? context.postId + : registry.select( editorStore ).getCurrentPostId(); const postType = context.postType ? context.postType : registry.select( editorStore ).getCurrentPostType(); registry .dispatch( coreDataStore ) - .editEntityRecord( 'postType', postType, context.postId, { + .editEntityRecord( 'postType', postType, postId, { meta: { [ args.key ]: value, },