-
Notifications
You must be signed in to change notification settings - Fork 4.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
a11y: Print script module live regions HTML in page HTML #65380
Conversation
Size Change: -411 B (-0.02%) Total Size: 1.77 MB
ℹ️ View Unchanged
|
8888f39
to
7496f88
Compare
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. |
Thank you for working on this and for the ping.
I can confirm the live regions need to be in the DOM on page load. For history, in the very first version of
@gziolo I'm afraid I don't know much about ES modules. Is your question related to the CSS part? It can be certainly moved to an inline style. Also, instead of repeating the style for all the 3 elements that need to be visually hidden, maybe the styling could be applied to a container element? Worth reminding this CSS is basically the screen-reader-text CSS rule used in WordPress core. For consistency, it's good to use exactly the same set of CSS declarations even though the A quick note; |
That seems fine technically and would make this less verbose. I'll apply that suggestion 👍
Nice, I'll see about switching to
That's correct, thanks for the suggestion, I'll use Safari in the future. |
7496f88
to
6e5f9b4
Compare
I've applied the suggestions and:
This is ready for another round of review, testing, and/or feedback. |
Excellent, I processed the proposal with a fresh perspective and responses from @afercia and @sirreal. I think it's a perfect trade-off for the use case. It diverges further from how |
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.
It tests well for me 💯
The code for script module is only active in the Gutenberg for now so we can proceed with confidence.
I created #65409 as a follow-up to remove some redundant styling mentioned in #65380 (comment) from the |
This script module requires an additional change that will be landed separately before it can be landed. See WordPress/gutenberg#65380.
This script module requires an additional change that will be landed separately before it can be landed. See WordPress/gutenberg#65380.
What?
Fix potential issues where
@wordpress/a11y
script modulespeak
may not be detected and announced by accessibility software, in particular when dynamically loading the module.Why?
While working on #65123, I noticed that the live regions would not be announced on their first update but would on subsequent updates.
This is caused because accessibility software needs to detect the live regions in order to announce them. The
@wordpress/a11y
script module was adding the live regions correctly when the module was loaded, but when loaded on demand (import( '@wordpress/a11y' ).then( { speak } ) => speak( 'announce me.' )
) the update would happen before the live region was detected and the announcements were missed.The
wp-a11y
script includes code to prevent it from duplicated the DOM elements that are added on page load so this should not present any conflicts with the a11y script's setup.How?
Update the a11y script module so that it does not register the live regions but expects them to be present on the page.
A function is added to add the HTML for the live regions when the
@wordpress/a11y
script module may be present (is enqueued or is in the import map).This reverts some of the changes from #65101 to pass the localized string through the script module. Now the localized string is simply printed on the page.
Testing Instructions
This can be tested easily with #65123. Screen readers should read (localized) "Page Loaded." the first (and every subsequent time) that the interactivity router navigates.
Screenshots or screencast
demo.mov
(The extra "polite" aria-live region in the screen capture is from the Interactivity API).