Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 11 additions & 19 deletions packages/interactivity-router/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,11 +221,6 @@ interface Store {
navigation: {
hasStarted: boolean;
hasFinished: boolean;
message: string;
texts?: {
loading?: string;
loaded?: string;
};
};
};
actions: {
Expand All @@ -240,7 +235,6 @@ export const { state, actions } = store< Store >( 'core/router', {
navigation: {
hasStarted: false,
hasFinished: false,
message: '',
},
},
actions: {
Expand Down Expand Up @@ -403,30 +397,28 @@ function a11ySpeak( messageKey: keyof typeof navigationTexts ) {
} catch {}
} else {
// Fallback to localized strings from Interactivity API state.
// @todo This block is for Core < 6.7.0. Remove when support is dropped.

// @ts-expect-error
if ( state.navigation.texts?.loading ) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just confirming, does this state come from the server in WP 6.6 and 6.5? Was it removed in WP core for WP 6.7?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WordPress/wordpress-develop#7304 is expected to remove it in 6.7 and switch to the script module data passing. It was in the Interactivity API store state before that change, so in WordPress 6.6 it was in the Interactivity API store state.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent. Thank you for confirmation.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I may not have answered that fully. Yes, it's server provided state in WordPress 6.6.

// @ts-expect-error
navigationTexts.loading = state.navigation.texts.loading;
}
// @ts-expect-error
if ( state.navigation.texts?.loaded ) {
// @ts-expect-error
navigationTexts.loaded = state.navigation.texts.loaded;
}
}
}

const message = navigationTexts[ messageKey ];

if ( globalThis.IS_GUTENBERG_PLUGIN ) {
import( '@wordpress/a11y' ).then(
( { speak } ) => speak( message ),
// Ignore failures to load the a11y module.
() => {}
);
} else {
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' : '' );
}
import( '@wordpress/a11y' ).then(
( { speak } ) => speak( message ),
// Ignore failures to load the a11y module.
() => {}
);
}

// Add click and prefetch to all links.
Expand Down