-
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
Merged
cbravobernal
merged 11 commits into
trunk
from
fix/restrict-supported-field-types-in-bindings
Oct 18, 2024
+176
−23
Merged
Changes from 3 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
3c8f338
Filter fields by type in post meta
SantosGuillamot c21e55a
Add e2e test
SantosGuillamot ece9a68
Allow only strings
cbravobernal 02bcdc4
Update test to expect numbers and integers to be hidden
artemiomorales 6f8397c
Update tests to check for label instead of key
artemiomorales 3ef22f9
Adapt object custom field
SantosGuillamot 48485b1
Adapt e2e tests
SantosGuillamot 98e41bd
Add `type` prop to `getFieldsList`
SantosGuillamot 346faed
Adapt testing source
SantosGuillamot 41d6aba
Reduce diff
SantosGuillamot 1512311
Add `attribute` to dependencies
SantosGuillamot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 could add the filter here:
https://github.com/WordPress/gutenberg/blob/0010f6355a37b647f2246ddbd88bba886a84a9cb/packages/core-data/src/resolvers.js#L1011-L1018
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.
Hmm, I think it makes more sense to have the check here in
packages/editor/src/bindings/post-meta.js
. That makes the check more specific to bindings and keeps the related exceptions together, whereasgetRegisteredPostMeta
seems better to me conceptually as a more agnostic function.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.
I believe the conditional should look like this, adding some handling for default values, otherwise valid fields will get skipped over in templates where
entityMetaFields
is undefined due topostId
being undefined. Consequently, this also fixes some broken tests.It might cause other things to break, though — I haven't been able to confirm that yet:
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.
I agree
getRegisteredPostMeta
should be agnostic to bindings and in other case an object or an array could be a valid value. I want to explore if it should happen in the bindings hooks instead of just post meta.And it's true that we can't just check against
string
becauseundefined
is also a valid value. I'll spend some time today exploring the best way to handle this.