-
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
Group: Make nav element selectable and add UI for ariaLabel #68611
base: trunk
Are you sure you want to change the base?
Conversation
Size Change: +132 B (+0.01%) Total Size: 1.84 MB
ℹ️ View Unchanged
|
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. |
{ tagName === 'nav' && ( | ||
<TextControl | ||
label={ __( 'Navigation label' ) } | ||
value={ ariaLabel || '' } | ||
__next40pxDefaultSize | ||
__nextHasNoMarginBottom | ||
onChange={ ( value ) => { | ||
setAttributes( { ariaLabel: value } ); | ||
} } | ||
help={ __( | ||
'Add a label to describe the purpose of this navigation element.' | ||
) } | ||
/> | ||
) } |
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's just time to add a full standardized UI for the aria label block support 🤔
In reality users can already set this attribute in code today. It just doesn't have a UI... I'm not sure only showing it for the nav
tag name makes it more clear 🤔
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's just time to add a full standardized UI for the aria label block support
That's certainly true, and maybe we should do so in the future.
Personally, I'm cautious about changing the block support spec right now. For now, I prefer to expose the UI only to the Group block. I'd like to hear other people's opinions on this.
onChange={ ( value ) => { | ||
setAttributes( { | ||
tagName: value, | ||
ariaLabel: value === 'nav' ? ariaLabel : 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.
This is going to override already existing aria labels when the tag name is changed to and from nav
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 should work like this:
- When changed TO a
nav
element: existing aria-Label is maintained - When changed FROM a
nav
element: aria-Label is removed
Aside: Do you recall an issue about displaying the tagName in the ListView? Because it feels relevant to this change. But I can't find the discussions. I am saying it is relevant because it can help (advanced) users quickly locate the nav elements or items that need to be updated to navs. |
Fixes #67407
What?
This PR makes it possible to operate the following two things from the Advanced panel in the Group block:
nav
element as an HTML element (tagName
attribute)ariaLabel
attribute)Why?
These two are already available as internal attributes. However, the only way to change them is to edit the HTML directly. (See TT5's example).
To help users create more accessible content, I propose adding a UI for these attributes to the Advanced panel.
How?
When an element other than a nav element is selected, the navigation label is removed. This is to prevent HTML like the one below from being saved:
This does not mean that the
aria-label
attribute cannot be used on elements other than thenav
element, but for now I will limit it to thenav
element.Additionally, we need some good help text to prevent users from misusing this UI. I also welcome your feedback on the help text.
Testing Instructions
nav
.aria-label
attribute is added.nav
.aria-label
attribute is NOT added.Screenshot