Skip to content

Nav offcanvas - creating a menu from the block list view transfers focus back to canvas #47018

Open

Description

@getdave

As reported in #46939 (comment), when inserting blocks focus (note this is different to block selection) may be transferred to the canvas.

Instead focus should remain within/return to the context of the offcanvas from which you added the block.

Activity

  1. changed the title [-]Nav offcanvas - inserting block transfers focused back to canvas[/-] [+]Nav offcanvas - inserting block transfers focus back to canvas[/+] on Jan 10, 2023
  2. talldan commented on Jan 11, 2023

    @talldan
    Contributor

    It's weird because the Inserter component has selectBlockOnInsert={ false } specified:

    <Inserter
    ref={ ref }
    rootClientId={ clientId }
    position="bottom right"
    isAppender={ true }
    selectBlockOnInsert={ false }
    shouldDirectInsert={ false }
    __experimentalIsQuick
    { ...props }
    />

    I guess that prop doesn't work.

    Edit: I think the issue in the video is that a menu was created, and I think it's that causing the focus loss. In general usage I don't see any issues with focus being transferred.

  3. getdave commented on Jan 11, 2023

    @getdave
    ContributorAuthor

    I have a sneaking suspicion that "focus" and "selected" are different things. I could be wrong...

  4. getdave commented on Jan 11, 2023

    @getdave
    ContributorAuthor

    I figured this out. It's as @talldan suspected.

    If you have no menus then inserting a Navigation block will create an "auto menu" which is basically a Page List block.

    If you then use the Nav list view to insert a new block into this menu then a new Navigation menu (wp_navigation) will be created. However the creation of the menu causes focus to be lost from the list view and transfered to the editor iframe.

    Note how in the video below the focus gets transferred to the iframe when the menu is created. Note also that once the menu is created and I add a item to the menu, focus is handled correctly.

    Screen.Capture.on.2023-01-11.at.10-05-06.mp4

    When a menu is created the focus should remain in the Nav list view.

  5. getdave commented on Jan 11, 2023

    @getdave
    ContributorAuthor

    I tested this some more and I found that the selected block in the editor state is the Navigation block. But the focus is not on that block - somehow it ends up on an iframe.

    I suspect this may be a wider bug...

  6. jasmussen commented on Jan 13, 2023

    @jasmussen
    Contributor

    CC: @ellatrix per the iframe.

  7. added
    [Type] BugAn existing feature does not function as intended
    on Jan 26, 2023
  8. changed the title [-]Nav offcanvas - inserting block transfers focus back to canvas[/-] [+]Nav offcanvas - creating a menu from the block list view transfers focus back to canvas[/+] on Jan 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    [Block] NavigationAffects the Navigation Block[Focus] Accessibility (a11y)Changes that impact accessibility and need corresponding review (e.g. markup changes).[Type] BugAn existing feature does not function as intended

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions