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

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

Open
getdave opened this issue Jan 10, 2023 · 5 comments
Labels
[Block] Navigation Affects the Navigation Block [Focus] Accessibility (a11y) Changes that impact accessibility and need corresponding review (e.g. markup changes). [Type] Bug An existing feature does not function as intended

Comments

@getdave
Copy link
Contributor

getdave commented Jan 10, 2023

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.

@getdave getdave added [Focus] Accessibility (a11y) Changes that impact accessibility and need corresponding review (e.g. markup changes). [Block] Navigation Affects the Navigation Block [a11y] Keyboard & Focus labels Jan 10, 2023
@draganescu draganescu changed the title Nav offcanvas - inserting block transfers focused back to canvas Nav offcanvas - inserting block transfers focus back to canvas Jan 10, 2023
@talldan
Copy link
Contributor

talldan commented Jan 11, 2023

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.

@getdave
Copy link
Contributor Author

getdave commented Jan 11, 2023

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

@getdave
Copy link
Contributor Author

getdave commented Jan 11, 2023

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.

@getdave
Copy link
Contributor Author

getdave commented Jan 11, 2023

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...

@jasmussen
Copy link
Contributor

CC: @ellatrix per the iframe.

@getdave getdave added the [Type] Bug An existing feature does not function as intended label Jan 26, 2023
@getdave getdave 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 Jan 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Navigation Affects the Navigation Block [Focus] Accessibility (a11y) Changes that impact accessibility and need corresponding review (e.g. markup changes). [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

No branches or pull requests

4 participants