WordPress / gutenberg

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

Regression in Shift+Tab during writing mode #51876

Closed stokesman closed 1 year ago

stokesman commented 1 year ago

Description

In 6.2.2 pressing Shift+Tab moves focus to the block toolbar. In trunk, it moves to the editor toolbar.

Step-by-step reproduction instructions

  1. In the Post Editor insert or focus a block and begin typing
  2. Press Shift+Tab
  3. Observe that focus moved to the editor toolbar

Screenshots, screen recording, code snippet

Expected behavior in 6.2.2

https://github.com/WordPress/gutenberg/assets/9000376/ce64f88e-9c89-438b-9327-4997a202d7cd

Regression in trunk

https://github.com/WordPress/gutenberg/assets/9000376/ca9130f0-c5f8-4316-99c2-7b44a2302039

Environment info

Chrome on macOS

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

t-hamano commented 1 year ago

I was able to reproduce it too, tested on Windows 11.

https://github.com/WordPress/gutenberg/assets/54422211/e28bd7e4-e07b-44d5-82e7-77d93edc765e

jeryj commented 1 year ago

I can take a look at this. I probably accidentally broke it with https://github.com/WordPress/gutenberg/pull/51548. Thanks for catching this!

jeryj commented 1 year ago

Nevermind - it seems unrelated to my changes. I'll keep debugging it, but I'm not sure what would have caused it at this point.

t-hamano commented 1 year ago

I used git bisect to identify the commit where this problem occurred. The commit hash is a147d47 and the corresponding PR is #51623.

The following commands can be used to temporarily revert this commit to make sure that the problem does not occur.

git checkout trunk
git checkout -b test/toolbar
git revert a147d47

However, it is a bit difficult for me to see why replacing Reakit with Ariakit would have caused this problem 😅

jeryj commented 1 year ago

Nice find! It seems like it's something with the toolbar not being rendered early enough. If the toolbar is present on the page, shift + tab will work to move focus into the toolbar. If the toolbar isn't visible, it will send focus to the first tabstop outside the editor canvas.

https://github.com/WordPress/gutenberg/assets/967608/d1ee998d-d07e-41f6-ac43-c802ae8be931

draganescu commented 1 year ago

This is weird because with top toolbar the toolbar is always there. But if you do this:

it doesn't work after a random ESC key press!

draganescu commented 1 year ago

The alt + F10 shortcut works more predictable and focuses the block toolbar even after it's unmounted.

jeryj commented 1 year ago

I commented on https://github.com/WordPress/gutenberg/pull/52196#issuecomment-1634459455 to discuss this more, but this is a better place for the conversation.

We should figure out:

The shift + tab behavior in the editor has been debated before. Is this a moment we should use to reconsider the behavior of navigating between toolbars?