-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Interactivity API: Use a11y Script Module in Gutenberg #65123
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
Merged
sirreal
merged 16 commits into
trunk
from
update/use-a11y-module-for-interactivity-router
Sep 17, 2024
Merged
Changes from 1 commit
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
29999f8
Use @wordpress/a11y to announce to screen readers
sirreal 2d5317d
Only use a11y module in GUTENBERG_PLUGIN
sirreal 8409612
Add interacitivty-router script dependency on a11y
sirreal 3afbd51
Load translated strings using script module data passing
sirreal 771e61c
Fix i18n domain to use Core translations.
sirreal 1019f5b
Add extra fallback in case a11y module does not load
sirreal adbfd46
Fix lints
sirreal 85a7d02
Remove extra fallback
sirreal 6a21c9c
Update package lock
sirreal f64d420
Add comment to gutenberg_register_interactivity_script_module_data_hooks
sirreal 0b7e978
Remove ariaLive param from a11yAnnounce
sirreal 63a1ffa
Move loaded data state out of texts object
sirreal 71515b6
Improve a11yAnnounce param type
sirreal 325249f
Rename function a11ySpeak
sirreal c9f0940
Add store type to allow texts
sirreal 85821fd
Add fallback for localized texts
sirreal File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Fix lints
- Loading branch information
commit adbfd46eed5aae2a518c2e7470b9cbaf872a70bc
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,7 +25,10 @@ function gutenberg_reregister_interactivity_script_modules() { | |
| '@wordpress/interactivity-router', | ||
| gutenberg_url( '/build-module/interactivity-router/index.min.js' ), | ||
| array( | ||
| array( 'id' => '@wordpress/a11y', 'import' => 'dynamic' ), | ||
| array( | ||
| 'id' => '@wordpress/a11y', | ||
| 'import' => 'dynamic', | ||
| ), | ||
| '@wordpress/interactivity', | ||
| ), | ||
| $default_version | ||
|
|
@@ -34,18 +37,18 @@ function gutenberg_reregister_interactivity_script_modules() { | |
| add_action( 'init', 'gutenberg_reregister_interactivity_script_modules' ); | ||
|
|
||
| function gutenberg_register_interactivity_script_module_data_hooks() { | ||
gziolo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| if ( ! has_filter( 'script_module_data_@wordpress/interactivity-router', array( wp_interactivity(), 'filter_script_module_interactivity_router_data' ) ) ) { | ||
| add_filter( | ||
| 'script_module_data_@wordpress/interactivity-router', | ||
| function ( $data ) { | ||
| if ( ! isset( $data['i18n'] ) ) { | ||
| $data['i18n'] = array(); | ||
| } | ||
| $data['i18n']['loading'] = __( 'Loading page, please wait.', 'default' ); | ||
| $data['i18n']['loaded'] = __( 'Page Loaded.', 'default' ); | ||
| return $data; | ||
| if ( ! has_filter( 'script_module_data_@wordpress/interactivity-router', array( wp_interactivity(), 'filter_script_module_interactivity_router_data' ) ) ) { | ||
gziolo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| add_filter( | ||
| 'script_module_data_@wordpress/interactivity-router', | ||
| function ( $data ) { | ||
| if ( ! isset( $data['i18n'] ) ) { | ||
| $data['i18n'] = array(); | ||
| } | ||
| ); | ||
| } | ||
| $data['i18n']['loading'] = __( 'Loading page, please wait.', 'default' ); | ||
| $data['i18n']['loaded'] = __( 'Page Loaded.', 'default' ); | ||
| return $data; | ||
| } | ||
| ); | ||
| } | ||
| } | ||
| add_action( 'after_setup_theme', 'gutenberg_register_interactivity_script_module_data_hooks', 20 ); | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. With the latest changes to use the localized fallback strings (passed via Interactivity API), if I disable this filter it correctly uses the those strings as a fallback. #65129 proposes adding this filter to Core. |
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.