-
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
Make the withNotices notices announced by assistive technologies #9443
Conversation
@@ -21,7 +21,7 @@ function Notice( { className, status, children, onRemove = noop, isDismissible = | |||
'is-dismissible': isDismissible, | |||
} ); | |||
return ( | |||
<div className={ classNames }> | |||
<div className={ classNames } role="alert"> |
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 for this improvement @afercia! I did some tests, and it looks like we are applying the role="alert" to a div that also contains a dismiss icon button. So for example in the max upload error message we get this as the alert message:
Maybe we can apply the role to a div that does not contain the IconButton, so we avoid referencing the dismiss as part of the alert message.
(To easily replicate the problem we can limit the site upload limit by adding the following two lines to .htaccess file php_value upload_max_filesize 1M, php_value post_max_size 1M)
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.
@jorgefilipecosta thanks, yep noticed that and can replicate in an easier way (I'm on nginx - VVV, no .htaccess here 😉):
The problem is if the notice content is not a string, then there's no inner wrapper:
{ isString( children ) ? <div className="components-notice__content">{ children }</div> : children } |
That leads me to the question: why components-notice__content
shouldn't be rendered when the children is not a string?
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.
Ah hm seems to me that's because originally the wrapper was a <p>
element, so it made sense to avoid to wrap other elements in a paragraph:
d64de0f#diff-90222e8dfd0cf666132b45557dab1ba9R23
but now that the wrapper is a div, I think it can just be always rendered.
I've tested it extensively in Windows and unfortunately it doesn't work so well. The thing is, I can think of two options:
|
d97f1e3
to
7e9f6ca
Compare
Although support for Aside issue: I'd greatly appreciate some help to understand why the |
52f63aa
to
488c121
Compare
Going to change the PR title, as it doesn't use a role=alert any longer. |
As a passing comment, the changes here as currently proposed would conflict with / duplicate the spoken messages triggered by notices created through the notices module. I don't know that it's tracked anywhere, but I foresee that Previously: #9617 |
Timing issues 🙂This PR was made a few days before the notices module one. I'd agree consolidating in an more abstracted implementation is the best way to go. @gziolo @aduth no objections in closing this PR: honestly, I wouldn't know where to start to re-implement However, quick question: is the notices module able to handle also "in place" notices besides the ones at the top of the editor? We'd need something to announce notices that appear within other components, for example: the contrast checker: notices when the apiFetch response is invalid / errors: allowed file types: etc. etc. Also, some notices (e.g. the template validation one) appear on page load. We should make sure the |
Yes. This is possible as @aduth explained:
However, this needs to be implemented this way. I think it would solve also a related issue with multiple notices showing up in those components. I think I saw PRs trying to fix it the other day. Saying that I will close this PR and copy my note to the parent issue to give a direction for someone who would like to fix it. Thanks for working on that PR 💯 |
Description
The notices created by
withNotices
convey important information to users but they're not announced by screen readers. This PR simply adds arole="alert"
attribute to the notice wrapper. Reference: https://www.w3.org/TR/wai-aria-1.1/#alertSo in this case, this is all it takes to make the notices text announced by screen readers.
To test, use a screen reader. On a mac you can use Safari and VoiceOver (Cmd+F5).
To make one of these notices appear, you can set background and text color on a paragraph in a way to make the contrast ratio notice appear.
Before this change, nothing is announced. After this change, VoiceOver automatically announces the notice text:
Other similar notices are used in the blocks, typically when dragging e media file within a block that accepts media. You can, for example, set "Offline" in your dev tools, drag an image on an Image block, and see the related norice appear (and be announced).
Fixes #9442