Skip to content

Commit

Permalink
Add extra fallback in case a11y module does not load
Browse files Browse the repository at this point in the history
  • Loading branch information
sirreal committed Sep 12, 2024
1 parent 4d8d9cb commit 47aee2a
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions packages/interactivity-router/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -394,8 +394,16 @@ function a11yAnnounce(
if ( globalThis.IS_GUTENBERG_PLUGIN ) {
import( '@wordpress/a11y' ).then(
( { speak } ) => speak( message, ariaLive ),
// Silence errors.
() => undefined
// Use the fallback Interactivity API implementation if the a11y
// Script Module cannot be loaded.
() => {
state.navigation.message =
// Announce that the page has been loaded. If the message is the
// same, we use a no-break space similar to the @wordpress/a11y
// package: https://github.com/WordPress/gutenberg/blob/c395242b8e6ee20f8b06c199e4fc2920d7018af1/packages/a11y/src/filter-message.js#L20-L26
message +
( state.navigation.message === message ? '\u00A0' : '' );
}
);
} else {
state.navigation.message =
Expand Down

0 comments on commit 47aee2a

Please sign in to comment.