-
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
Heading Block: Show default block name in list view when content is empty #59827
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. |
Size Change: +214 B (0%) Total Size: 1.71 MB
ℹ️ View Unchanged
|
This PR seems to have caused the mobile unit test to fail. I'll try to find out the cause 👀 |
Update: The unit tests seem to have been fixed in db6defd. Some E2E tests are failing, but looking at the error log it seems to be happening with other PRs as well. It has also been reported on Slack. https://wordpress.slack.com/archives/C02QB2JS7/p1710332640293859 |
@t-hamano Is this bug present in WP 6.5 RC2? If so then we'd need to get a fix into RC3. |
Yes. This problem should first occur in WP6.5. I could not reproduce this problem with WP6.4. Because #43204, which is probably causing this issue, is part of Gutenberg17.3 and first shipped in WP6.5. |
Note: This issue occurs after inserting an empty Heading block, saving and reloading the post. I updated the PR testing instructions and E2E test. |
Adding an early return might also work in this case, which for Untested example: if ( ! customName || content.lenght === 0 ) {
return;
} The Edit: we can update the check here because an empty return won't work for the gutenberg/packages/block-library/src/heading/index.js Lines 36 to 38 in 44cccd6
|
Thanks for the review! Sorry, I just caught a cold and my response may be delayed. If we need to backport this PR to next week's RC3, feel free to push it 🙏 |
No worries and fast recovery, @t-hamano! |
Let's try to bring this into RC3. @Mamaduka are you going to have bandwidth to work on this? |
@getdave, yes. I'll push the update in a bit. |
@@ -30,15 +30,16 @@ export const settings = { | |||
const { content, level } = attributes; | |||
|
|||
const customName = attributes?.metadata?.name; | |||
const hasContent = content?.length > 0; |
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.
This will work for both undefined
and RichTextData
.
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.
Nice, that's handy! TIL the RichTextData
class has a length
getter 👍
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.
@@ -30,15 +30,16 @@ export const settings = { | |||
const { content, level } = attributes; | |||
|
|||
const customName = attributes?.metadata?.name; | |||
const hasContent = content?.length > 0; |
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.
Nice, that's handy! TIL the RichTextData
class has a length
getter 👍
@Mamaduka Thanks for the follow-up! |
…mpty (#59827) Co-authored-by: t-hamano <wildworks@git.wordpress.org> Co-authored-by: Mamaduka <mamaduka@git.wordpress.org> Co-authored-by: andrewserong <andrewserong@git.wordpress.org> Co-authored-by: getdave <get_dave@git.wordpress.org>
I just cherry-picked this PR to the update/packages-rc2-6.5 branch to get it included in the next release: c20a56d |
…mpty (#59827) Co-authored-by: t-hamano <wildworks@git.wordpress.org> Co-authored-by: Mamaduka <mamaduka@git.wordpress.org> Co-authored-by: andrewserong <andrewserong@git.wordpress.org> Co-authored-by: getdave <get_dave@git.wordpress.org>
…mpty (WordPress#59827) Co-authored-by: t-hamano <wildworks@git.wordpress.org> Co-authored-by: Mamaduka <mamaduka@git.wordpress.org> Co-authored-by: andrewserong <andrewserong@git.wordpress.org> Co-authored-by: getdave <get_dave@git.wordpress.org>
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.
Fds
Probably caused regression by #43204
What?
This PR displays the default block name in list view when the Heading block content is "empty".
Before
After
Why?
My understanding is that #43204 changed the content type of the Heading block from
string
torich-text
. As a result, thecontent
passed to the__experimentalLabel
prop will be an object like the one below, even if the content is empty.As a result, the content will be considered "not empty" and will not be displayed in the list view.
How?
Use
toHTMLString()
to convert the content to an HTML string beforehand. Additionally, I added e2e tests to prevent regressions.Testing Instructions
List View
Accesibility
This label is also used when the context is
accesibility
. There seems to be no regression in this regard, but please switch to select mode and check that thearia-label
is displayed correctly in the developer tools.Screenshots or screencast
79494fdcab1ecc63f5e753d0a7bc996b.mp4