Skip to content

Commit

Permalink
Preload menu REST API requests on new navigation editor. (#34364)
Browse files Browse the repository at this point in the history
* Preload menu data

* Fix lint.
  • Loading branch information
spacedmonkey authored Aug 30, 2021
1 parent 0dc7ad2 commit fa4f49d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 7 additions & 0 deletions lib/navigation-page.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ function gutenberg_navigation_init( $hook ) {
return;
}

$preload_paths = array(
'/__experimental/menu-locations',
array( '/wp/v2/pages', 'OPTIONS' ),
array( '/wp/v2/posts', 'OPTIONS' ),
);

$settings = array_merge(
gutenberg_get_default_block_editor_settings(),
array(
Expand All @@ -46,6 +52,7 @@ function gutenberg_navigation_init( $hook ) {
array(
'initializer_name' => 'initialize',
'editor_settings' => $settings,
'preload_paths' => $preload_paths,
)
);

Expand Down
2 changes: 1 addition & 1 deletion packages/edit-navigation/src/hooks/use-menu-locations.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export default function useMenuLocations() {
const fetchMenuLocationsByName = async () => {
const newMenuLocationsByName = await apiFetch( {
method: 'GET',
path: '/__experimental/menu-locations/',
path: '/__experimental/menu-locations',
} );

if ( isMounted ) {
Expand Down

0 comments on commit fa4f49d

Please sign in to comment.