-
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
Remove role
attribute when set to null
in data-wp-bind
#54608
Conversation
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.
LGTM, Mario! 🎉
Oh, can you include an entry in the changelog? Thanks! |
Size Change: +58 B (0%) Total Size: 1.62 MB
ℹ️ View Unchanged
|
Sure! I just did it. |
Merging this PR now to ensure it is included in the next release. If there is something else missing we can always include it in a future patch. |
The Preact team released v10.18.0, which includes a fix for this: https://github.com/preactjs/preact/releases/tag/10.18.0 I've added it to the roadmap so we don't forget to make this change. |
What?
In this pull request I'm adding a workaround to handle the
role
attribute properly until it is solved in Preact. Basically, when we pass anull
value torole
, it is using and empty string instead of removing the HTML element. I submitted this issue to Preact repo.As part of this, I also removed the Server Side Rendering attributes to fix the issue reported here. After this fix it seems that the
aria-modal
androle
attributes are properly removed in the Server Side Rendering and after opening and closing the menu.I didn't add logic to remove the
aria-label
because it was there before adding the Interactivity API, and some users may be using that. Additionally, as reported in the issue, it shouldn't affect the accessibility.Why?
Right now, there is no way to remove the
role
attribute dynamically, which ends up in an empty value, which is not valid HTML.How?
I added a workaround to handle the
role
attribute until the issue in Preact is solved. Additionally, I removed the attributes for the Server Side Rendering.Testing Instructions
div
element with classwp-block-navigation__responsive-dialog
doesn't havearia-modal
orrole
attributes.div
hasaria-modal="true"
androle="dialog"
.