-
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 support: Preserve aria-label value in comment delimiter #69002
Conversation
@@ -15,11 +16,22 @@ import { fixCustomClassname } from './fix-custom-classname'; | |||
* @return {WPBlock} Fixed block object | |||
*/ | |||
export function applyBuiltInValidationFixes( block, blockType ) { |
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.
If this approach works, we may be able to apply a similar approach to the anchor support as well (See #51402).
This means adding a new function like fixAnchor()
here 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 wonder if it would be more performant to have a single fixGlobalAttributes
method that fixes all these cases instead of multiple parsers.
This isn't a blocker; it's just something to keep in mind after everything is merged, including the fixAnchor
solution.
Size Change: +42 B (0%) Total Size: 1.84 MB
ℹ️ View Unchanged
|
Flaky tests detected in a71ec20. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/13107958080
|
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. |
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.
Thank you, @t-hamano!
The code looks good and both scenarios test well for me ✅
@Mamaduka Thanks for the review! |
This comment made me realize that I was missing some server-side processing for the |
Fixes #68764
Alternatives to #68735
What?
This PR changes the schema for the
ariaLabel
block support to save its value in the comment delimiter.That is, the block HTML will be updated to look like this:
Why?
The current schema references the
aria-label
attribute if it exists in the HTML markup. This works fine for the Group block, whose HTML markup is preserved, but the value cannot be referenced in the Navigation block, whose HTML markup is not preserved.As a result, as reported in #68719, when you update a template that contains a Navigation block with the
aria-label
attribute,the aria-label
value disappears.In Twenty Twenty-Five and Twenty Twenty-Four,
aria-label
is applied to some Navigation blocks. I believe that the disappearance of this value is a issue from an accessibility perspective.How?
Remove the
source
,attribute
, andselector
fields from the schema definition. This will break Group blocks that already supportariaLabel
, so something needs to be done about it.I noticed that there is already a fix for block validation regarding custom class names (
fixCustomClassname()
function). I used this process to automatically migrate the attributes via thefixAriaLabel()
function so that block validation does not fail.To solve this problem, I considered three approaches (See #68764). I believe this approach is the best.
Testing Instructions
Group Block
Navigation Block
About
,Privacy
, andSocial
.aria-labe
l values should not have disappeared.aria-label
values should not have disappeared.