-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Image: do not display empty caption. #674
Conversation
blocks/library/image/index.js
Outdated
@@ -95,7 +95,7 @@ registerBlock( 'core/image', { | |||
return ( | |||
<figure className="blocks-image"> | |||
<img src={ url } alt={ alt } /> | |||
{ caption || !! focus ? ( | |||
{ caption.length || !! focus ? ( |
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.
caption && caption.length
maybe. I think caption
could be undefined
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.
Should we also check in save
?
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.
Yeah the ! caption
check is probably not enough since the caption shape changed.
! caption || ! caption.length
to match the edit?
ac61af1
to
27c97a9
Compare
27c97a9
to
9c8a9ac
Compare
Oops, I must have overlooked this and separately put together #684. However, the changes there are more complete:
I would need to incorporate the |
Okay, I see now it's mainly with newly created blocks. I'm wondering if it's worthwhile to always default these to an empty array so we don't have to worry about whether it's undefined or an array. |
Sorry to hijack this, but I'm going to close in favor of #684. |
Fixes #673