-
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
More block: Fix React warning when adding custom text #61936
Conversation
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
@@ -10,7 +10,7 @@ import { getDefaultBlockName, createBlock } from '@wordpress/blocks'; | |||
const DEFAULT_TEXT = __( 'Read more' ); | |||
|
|||
export default function MoreEdit( { | |||
attributes: { customText, noTeaser }, | |||
attributes: { customText = '', noTeaser }, |
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 add a default to the attribute definition? I think that's what a lot of blocks do
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.
Sometimes, attribute updates require deprecations. I think undefined values don't get serialized, while empty does.
I can double-check, but adding deprecation for a simple fix like this is probably not worth it. What do you think?
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, I was wrong. It looks like there's no need for deprecation, at least for the current case.
Size Change: -4 B (0%) Total Size: 1.75 MB
ℹ️ View Unchanged
|
Flaky tests detected in 52e3144. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/9222375264
|
Co-authored-by: Mamaduka <[email protected]> Co-authored-by: ellatrix <[email protected]>
Co-authored-by: Mamaduka <[email protected]> Co-authored-by: ellatrix <[email protected]>
What?
PR fixes a React warning triggered by the "More" block when updating the placeholder text.
Why?
This can happen when the value changes from
undefined
to other primitive values like string.How?
Set the default value to an empty string instead of
undefined
.Testing Instructions
Testing Instructions for Keyboard
Same.
Screenshots or screencast