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

Navigation block: requires double clicking to select/edit when using page list #45083

Closed
annezazu opened this issue Oct 18, 2022 · 10 comments · Fixed by #45143
Closed

Navigation block: requires double clicking to select/edit when using page list #45083

annezazu opened this issue Oct 18, 2022 · 10 comments · Fixed by #45143
Assignees
Labels
[Block] Page List Affects the Page List Block General Interface Parts of the UI which don't fall neatly under other labels. [Type] Bug An existing feature does not function as intended

Comments

@annezazu
Copy link
Contributor

annezazu commented Oct 18, 2022

Description

The "click to edit" overlay #35079 seems to be broken causing one to have to double click in quick succession in order to edit a navigation block. This seems specific to a post theme switch from a classic theme when the page list fallback is in place as I can't replicate when a "regular" navigation block is in place. cc @getdave

Step-by-step reproduction instructions

  1. Use 6.1 RC2 on a site.
  2. Convert from a classic theme to block with one menu in place.
  3. Try to select and edit the navigation block.

If you need a test site to make it easier, you can spin up a site with https://app.instawp.io/launch?t=fse-call-for-testing-17 from the last call for testing for the FSE Outreach Program. This will give a classic site. Uninstall Gutenberg, update to 6.1 RC2 via beta tester, then switch to TT3.

Screenshots, screen recording, code snippet

Here's a video showing the problem just after switching from a classic to block theme and needing to convert the page list links to blocks:

click.to.edit.needing.double.click.mov

I can't replicate after converting to links:

Uploading click to edit post conversion.mov…

Environment info

  • WordPress 6.1 RC2
  • TT2
  • No Gutenberg
  • Chrome

Please confirm that you have searched existing issues in the repo.

Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

Yes

@annezazu annezazu added [Type] Bug An existing feature does not function as intended General Interface Parts of the UI which don't fall neatly under other labels. [Block] Navigation Affects the Navigation Block labels Oct 18, 2022
@getdave
Copy link
Contributor

getdave commented Oct 19, 2022

Tested and confirmed this is a bug on RC2. You cannot select the Page List at all without double click.

@getdave
Copy link
Contributor

getdave commented Oct 19, 2022

I can confirm that turning off Overlay causes this issue to disappear. Therefore I believe this is the overlay interfering.

@getdave

This comment was marked as outdated.

@getdave
Copy link
Contributor

getdave commented Oct 19, 2022

Ok here I am testing on Gutenberg trunk.

  • initially I cannot click on the Page List in the canvas to select it
  • then I toggle the overlay to off.
  • now I can click in the canvas to select.
  • now I toggle the overlay back to Mobile again.
  • now I can click in the canvas to select (this is in contrast to the initial experience).

Why is this happening? What changes? Diving deeper....

Screen.Capture.on.2022-10-19.at.12-08-02.mp4

@getdave
Copy link
Contributor

getdave commented Oct 19, 2022

I can observe the same behaviour using the following markup:

<!-- wp:group {"layout":{"type":"constrained"}} -->
<div class="wp-block-group"><!-- wp:page-list /--></div>
<!-- /wp:group -->

Therefore I don't think this is specific to the Navigation block but rather the Page List block.

@getdave
Copy link
Contributor

getdave commented Oct 19, 2022

Narrowing this down some more. It seems that the Page List block as an inner block is not receiving the focusin event under certain conditions.

This is causing the onFocus callback of useRefEffect not to run for the Page List block. Instead it just runs for the wrapper block.

However, some changes in the editor seem to "trigger" the focus to work as you'd expect for the Page List. One example is simply going in and then out of Code Editor view. After doing that the focus works to allow you to select the inner Page List directly. See video:

Screen.Capture.on.2022-10-19.at.15-58-57.mp4

My current thinking is that something is blocking focusin from firing. Is it some piece of DOM overlay or a quirk of the JS... 🤔

@getdave
Copy link
Contributor

getdave commented Oct 19, 2022

Going deeper. The focusin handler is not registered on the Page List <ul> element. It appears is is removed by the cleanup function returned by useFocusHandler.

Before toggling Code Editor mode

Screen Shot 2022-10-19 at 16 22 11

Notice that the only event handler is that on the parent Group block.

After toggling Code Editor mode

Notice that the new handle on the <ul>.
Screen Shot 2022-10-19 at 16 24 26 (1)

@getdave
Copy link
Contributor

getdave commented Oct 19, 2022

I now believe the following

  • the clean up function of useFocusHandler is running for the Page List node.
  • useRefEffect will run it's cleanup if the ref changes.
  • the "ref" is passed via useMergeRefs here (notice that useFocusHandler is one of the hooks):
    const mergedRefs = useMergeRefs( [
    props.ref,
    useFocusFirstElement( clientId ),
    useBlockRefProvider( clientId ),
    useFocusHandler( clientId ),
    useEventHandlers( clientId ),
    useNavModeExit( clientId ),
    useIsHovered(),
    useIntersectionObserver(),
    useMovingAnimation( {
    isSelected: isPartOfSelection,
    adjustScrolling,
    enableAnimation,
    triggerAnimationOnChange: index,
    } ),
    useDisabled( { isDisabled: ! hasOverlay } ),
    ] );
  • by process of elimination if I removed useIntersectionObserver from the merged refs the ref remains stable and the thus the callback of useFocusHandler does not fire. This means the focus functionality works for Page List.

Therefore I believe the issue may lie in useIntersectionObserver or some quirk of how Page List interacts with that hook.

EOD for me here but can pick up again tomorrow.

@annezazu
Copy link
Contributor Author

Amazing job continuing to sleuth. Thank you.

@github-actions github-actions bot added the [Status] In Progress Tracking issues with work in progress label Oct 20, 2022
@getdave getdave added [Block] Page List Affects the Page List Block and removed [Block] Navigation Affects the Navigation Block labels Oct 20, 2022
@getdave getdave moved this from Todo to Needs Review in WordPress 6.1 Editor Tasks Oct 20, 2022
@getdave
Copy link
Contributor

getdave commented Oct 20, 2022

I think I now have a fix at #45143. Full explanation in that PR.

Repository owner moved this from Needs Review to Done in WordPress 6.1 Editor Tasks Oct 20, 2022
@priethor priethor removed the [Status] In Progress Tracking issues with work in progress label Nov 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Page List Affects the Page List Block General Interface Parts of the UI which don't fall neatly under other labels. [Type] Bug An existing feature does not function as intended
Projects
No open projects
6 participants