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

Removing an item from a menu in the Nav block list view causes a focus loss. #48017

Closed
getdave opened this issue Feb 13, 2023 · 6 comments · Fixed by #48204
Closed

Removing an item from a menu in the Nav block list view causes a focus loss. #48017

getdave opened this issue Feb 13, 2023 · 6 comments · Fixed by #48204
Assignees
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 Feb 13, 2023

Identified during a11y review #46939 (comment), when removing an item using the Nav block list view focus is completely lost. It should be returned to the previous node or at least somewhere within the list view.

@draganescu
Copy link
Contributor

Investigating this I learned that:

  • removing any block moves focus to the editor iframe
  • removing a submenu items, both in canvas and in the inspector, moves focus to document's body
  • removing a menu item via the canvas moves focus to the editor iframe
  • removing a menu item via the inspector moves focus to document's body

@draganescu
Copy link
Contributor

More investigation resulted in doubting the origina bug:

  • removing any block moves focus to the editor, removing a menu item via the canvas moves focus to the editor, moves focus to the editor iframe, but using contentWindow.document.activeElement shows the correct focus is applied to best available blocks in canvas
  • removing a menu item via the inspector moves the focus properly can't repro consistently my finding above
  • removing a submenu items, both in canvas and in the inspector, this is where focus is lost.

We need to manage focus where we do the transforms between link and submenu wither in the store like we foce select of previous block or in the blocks themselves.

@draganescu draganescu self-assigned this Feb 15, 2023
@draganescu
Copy link
Contributor

It seems there is a problem with replaceBlocks and how we use it to "transform" submenu to link. But many block operations use a selectionHelper that handles most selection following updating the block tree, including REPLACE_BLOCKS. Debugging this I learned that there are moments when the selection state is empty and because of the code here we return an empty selection state. Attempted a fix for this in #48105

The problem in this particular issue is a problem visible in the left hand list view as well, when replacing blocks the focus is not managed well and ends up on the body of the document.

@getdave
Copy link
Contributor Author

getdave commented Feb 21, 2023

@draganescu Great research. Thank you. As #48105 was closed what are the next steps here?

@draganescu
Copy link
Contributor

@getdave #48204 is the solution. Waiting for it to be reviewed and to land asap.

@getdave
Copy link
Contributor Author

getdave commented Mar 1, 2023

Great work on #48204 @draganescu 👏

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

Successfully merging a pull request may close this issue.

2 participants