Skip to content

Commit

Permalink
Add fallback for postId
Browse files Browse the repository at this point in the history
  • Loading branch information
SantosGuillamot committed May 17, 2024
1 parent 712f3ac commit 292b7da
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions packages/editor/src/bindings/post-meta.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
Expand Down

0 comments on commit 292b7da

Please sign in to comment.