-
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 Merge: guard for undefined attribute definition #17937
Conversation
@ellatrix thanks for adding this check, it will make it a lot easier to detect this problem 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.
@ellatrix thanks for adding this check, it will make it a lot easier to detect this problem 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.
I haven't tested it, so this review is purely going on the code.
It all makes sense to me, and the code is tidy. I left a couple of minor comments, nothing that should block merging.
); | ||
|
||
if ( ! attributeDefinition ) { | ||
if ( typeof attributeKey === 'number' ) { | ||
window.console.error( |
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.
Again this is another minor comment (which I don't think is a blocker for the PR). This seems like a very specific error, and I wonder whether it could be more generic by catching anything where value is defined but the type isn't a string, and adding something like this as the error:
`RichText needs an identifier prop that is the block attribute key of the attribute it controls. Its type is expected to be a string, but was ${ typeof attributeKey }`
Co-Authored-By: Daniel Richards <daniel.richards@automattic.com>
Description
Related: wordpress-mobile/WordPress-iOS#11950. Cc @SergioEstevao.
Currently, when a block implements a merge function, but doesn't set the
identifier
prop forRichText
, merging will error because selection cannot be restored. Instead, we should log an error and let the merge continue without restoring selection.How has this been tested?
Screenshots
Types of changes
Checklist: