-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Block bindings: allow the field types matching attribute types in bindings. #66174
Changes from 10 commits
3c8f338
c21e55a
ece9a68
02bcdc4
6f8397c
3ef22f9
48485b1
98e41bd
346faed
41d6aba
1512311
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -60,6 +60,7 @@ function getPostMetaFields( select, context ) { | |
entityMetaValues?.[ key ] ?? | ||
// When using the default, an empty string IS NOT a valid value. | ||
( props.default || undefined ), | ||
type: props.type, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That looks good. Source: https://developer.wordpress.org/reference/functions/register_meta/#parameters:
There is also undocumented "type": [ "string", "boolean" ] There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks a lot for the wrap-up 🙂 I think it could make sense to work on unifying the typing of block attributes and register meta somehow. For example, if in the future a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This nicely ties in with the feedback shared by @afercia at #63018 (comment). In this PR, we will see the first step toward filtering of the options presented for the block attribute based on its type that matches with the Post Meta's type. The next step would be offering more granular type system for all meta fields and block attributes. We will also have to enforce defining the type for custom block binding sources in the future. |
||
}; | ||
} | ||
} ); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We will need a more sophisticated utility in the future. See my notes in https://github.com/WordPress/gutenberg/pull/66174/files#r1804482542. The type can list multiple types, too.