WordPress / gutenberg

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

Inserter Constrained tabbing doesn't work in Edit mode #45973

Open afercia opened 1 year ago

afercia commented 1 year ago

Description

Likely broke in https://github.com/WordPress/gutenberg/pull/32824

The main block inserter is supposed to constrain tabbing with the Tab key within it. However, tabbing is not constrained when the editor is in 'Edit' mode. It only works when the editor is in 'Select' mode.

Note: I think this is not limited to the inserter and potentially affects any component with constrained tabbing that lives in the DOM immediately before (and I guess also after) the Writing Flow component.

Actually, WritingFlow is responsible for this wrong behavior. Specifically, useTabNav kicks in when tabbing away from the inserter and breaks the expected constrained tabbing behavior.

Why it only breaks in 'Edit' mode?

Step-by-step reproduction instructions

Aside: when tabbing within the inserter, at some point focus is on a visually hidden 'Close block inserter' button that shows only its tooltip. This isn't ideal, will create a separate issue.

Screenshots, screen recording, code snippet

To clarify the 'focus capture' behavior:

The two 'focus capture' elements in Edit mode, with a tabindex=0 attribute:

Screenshot 2022-11-22 at 09 05 48

The two 'focus capture' elements in Select mode, with no tabindex attribute:

Screenshot 2022-11-22 at 09 11 54

No response

Environment info

No response

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

afercia commented 1 year ago

NoteL