-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Hide X char in popup close button [accessibility] #11040
Conversation
src/ui/popup.js
Outdated
@@ -534,6 +534,7 @@ export default class Popup extends Evented { | |||
this._closeButton = DOM.create('button', 'mapboxgl-popup-close-button', this._content); | |||
this._closeButton.type = 'button'; | |||
this._closeButton.setAttribute('aria-label', 'Close popup'); | |||
this._closeButton.setAttribute('aria-hidden', ''); |
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.
Any reason not to set explicitly to true
as the ticket suggests?
this._closeButton.setAttribute('aria-hidden', ''); | |
this._closeButton.setAttribute('aria-hidden', 'true'); |
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.
@mourner This is my bad - I should've updated the PR to specify this change. I originally had 'true' but it failed CircleCI flow tests with this error: "Cannot call this._closeButton.setAttribute
with true
bound to value
because boolean [1] is incompatible with
string [2].". I looked up the setAttribute docs and it recommends using an empty string in the example: https://developer.mozilla.org/en-US/docs/Web/API/Element/setAttribute#example
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.
Maybe set to 'aria-hidden'
or otherwise add a comment? // The empty string is a recommended truthy value for setAttribute
. Seems a bit surprising/confusing, though there's relatively low maintenance burden here.
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.
Thanks for addressing! 👏 🙇 No change required by me, though the empty string being a recommended truthy value is definitely a TIL for me!
src/ui/popup.js
Outdated
@@ -534,6 +534,7 @@ export default class Popup extends Evented { | |||
this._closeButton = DOM.create('button', 'mapboxgl-popup-close-button', this._content); | |||
this._closeButton.type = 'button'; | |||
this._closeButton.setAttribute('aria-label', 'Close popup'); | |||
this._closeButton.setAttribute('aria-hidden', ''); |
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.
Maybe set to 'aria-hidden'
or otherwise add a comment? // The empty string is a recommended truthy value for setAttribute
. Seems a bit surprising/confusing, though there's relatively low maintenance burden here.
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.
aria-hidden
is not a boolean, it should be set to true
.
Hi @Malvoz thanks for checking on this. Unfortunately, I came across an error when trying to set it to true on our automated tests. I can look into why this is, but to double check you mean the attribute value must be set to boolean true and not string "true"? Thanks! |
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.
@avpeery I think the empty string thing in MDN only applies to specific attributes like disabled
and checked
, but not to aria-hidden
— it needs to explicitly be set to the "true"
string, and Flow shouldn't complain.
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 👍
Adding the attribute 'aria-hidden' hides the X character used for the close popup button from being voiced over when enabling voice over accessibility. As mentioned in the issue #11035 , the X character is announced as 'multiplication' or 'times'. Tested debug page with accessibility voice over turned on.
Launch Checklist