Skip to content
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

Preload request for fallback Navigation menu in Site Editor #50545

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
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
11 changes: 11 additions & 0 deletions lib/compat/wordpress-6.3/navigation-block-preloading.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,17 @@ function gutenberg_preload_navigation_posts( $preload_paths, $context ) {
'GET',
);

// Preload the request for a fallback navigation menu.
$preload_paths[] = array(
add_query_arg(
array(
'_embed' => 1,
),
'wp-block-editor/v1/navigation-fallback'
),
'GET',
);

return $preload_paths;
}
add_filter( 'block_editor_rest_api_preload_paths', 'gutenberg_preload_navigation_posts', 10, 2 );
5 changes: 4 additions & 1 deletion packages/core-data/src/resolvers.js
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,10 @@ export const getNavigationFallbackId =
async ( { dispatch } ) => {
const fallback = await apiFetch( {
path: addQueryArgs( '/wp-block-editor/v1/navigation-fallback', {
_embed: true,
// _embed is intentionally set as `1` (as opposed to `true`)
// to ensure preloading of this request works correctly.
// see https://github.com/WordPress/gutenberg/pull/48683/#issuecomment-1543726404.
_embed: 1,
} ),
} );

Expand Down