WordPress / gutenberg

The Block Editor project for WordPress and beyond. Plugin is available from the official repository.
https://wordpress.org/gutenberg/
Other
10.47k stars 4.18k forks source link

Navigation in Site View: Improve fallback loading #51802

Open scruffian opened 1 year ago

scruffian commented 1 year ago

What problem does this address?

When a site has no navigations, we load the fallback when you open the Navigation section of the Site View: janky

What is your proposed solution?

We should find a way to load the fallback earlier so that its already where when you navigate to the the Navigation section.

To replicate:

  1. Delete all your navigations
  2. Open the site editor
  3. Open the navigation section
  4. Notice that there is a small flash before the fallback is created.
getdave commented 1 year ago

~May be fixed by https://github.com/WordPress/gutenberg/pull/51795~

It won't be "fixed" but we can extend it by using the special button as a place to preload the fallback if there are no menus.

We can even do it on mouseenter like this:


// ...snip
const { getNavigationFallbackId } = useSelect( coreStore );
// ...snip
<NavigatorButton
    as={ SidebarNavigationItem }
    path="/navigation"
    withChevron
    icon={ navigation }
    onMouseEnter={ () => {
        getNavigationFallbackId();
    } }
>
getdave commented 1 year ago

Or we could check on the resolution status of getNavigationFallbackId and if it hasn't resolved then show a spinner.

So that's change the condition for isLoading to also consider status of Navigation Fallback resolver.

getdave commented 1 year ago

PR to fix is open https://github.com/WordPress/gutenberg/pull/52322