-
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
Improve accessibility of the Warning component in the block editor #67433
Conversation
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. |
@sarthaknagoshe2002 thanks for your PR. Good catch for adding the Unfortunately, testing with Safari and VoiceOver the Warning isn't announced. I guess because the editor sets focus on the newly inserted block. See in the screenshot below: focus is on the doubled 'More' block: I think a potential way to fix this would be setting focus on the Warning when it renders by using I'll leave a few comments in the review as well. |
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.
Left some comments
It seems to work fine in Chrome on macOS using the default screen reader. I also tested it on Safari, and it’s a bit buggy—I noticed it works intermittently. I’m currently investigating the issue and exploring possible solutions. |
@afercia I have now fixed things to make it work in safari.
Let me know this this requires any more changes. If not then I'll update the tests too. 😇 |
Also, the git hook seems to have modified the linting of some tsconfig.json file. |
@sarthaknagoshe2002 yes I think those changes should be reverted. As a last step, when everything is done, I guess the snapshot of the failing test should be updated.
|
@afercia I believe this is now ready to be merged. |
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.
Looks good to me, thanks @sarthaknagoshe2002 !
@WordPress/gutenberg-core as mentioned earlier, with this change all Warnings will receive focus when they render. There may be edge cases but I think it's OK as default behavior and I'm going to merge this PR. Just wanted to be sure everyone is aware of this change in case there are edge cases to address in follow-ups. |
I think having this component always receive focus when rendered can cause other accessibility issues. For example, create a pattern that already has broken blocks. When that pattern is rendered via a site editor or similar, the ec4af8494f02912743de2b5d683b4af2.mp4Another concern is that when I open a post with multiple broken blocks, the last Warning component gets focus immediately. I would like to confirm if this is an issue or not. |
@t-hamano thanks for your feedback. To me, moving focus is the most sensible default, especially when the Warning contains action buttons. Keyboard users will benefit from being able to immediately access the actions.
Yes I see your point. Should Warnings be rendered in the Patterns preview card in the first place? I didn't know of this behavior but to me it looks pretty weird. That is a preview, it should not contain interactive elements and they're so small anyways that I'd argue they're not usable at all. Screenshot:
Ideally, there should be only one Warning at a time. If the editor shows multiple warnings at the same time, they should also be all announced to screen reader users to provide an equivalent information. However, implementing a way to announce all warnings at the same time could be potentially very noisy and confusing. I'm really not sure how to address this potential edge case. |
I'll create a separate issue for the Warnings in the preview cards. |
I agree with @t-hamano that the Why?
TL;DR, let's avoid making similar changes to components that can be rendered multiple times and are widely used by block editors. |
I would also be in favour of reverting this. Autofocus on render is very likely to cause a number of knock on problems. The other changes to make the warnings perceivable and more prominent to assistive tech seem like good improvements however. |
I'm not opposed to a revertl. However:
Overall, the usage of the Warning is highly problematic and all these points should be addressed. If anyone can think at better ways to address these points, that would be very welcome. |
You can say that these warnings are mostly part of the content/canvas. Let's say you opened a documentation page with multiple warnings for experimental/unstable APIs. What are the expectations here? Do each of these warning messages try and move focus on itself, or are they just read as you get closer to actual experimental/unstable sections?
Ideally, we would have caught this broken behavior before merging this PR, but we are humans and sometimes miss things. I'll include a full revert in my PR (#68133). Let's reopen the issue and continue working on a solution. |
Was thinking at a potential different approach, I will comment on the issue and reopen it. |
Since the focus was causing issues, we could have simply removed that part, as the warning was being announced by the screen reader in other browsers (except Safari) without the focus. This way, the rest of the functionality remains untouched. |
Accessibility Fix: #62737
What?
This PR improves the Warning component in the block editor by enhancing its accessibility.
Why?
Currently, the Warning component only provides a visual cue without notifying screen readers, which limits accessibility. These changes ensure that the component is accessible to all users.
How?
Testing Instructions