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

Press Esc twice to deselect all blocks #47172

Closed
jasmussen opened this issue Jan 16, 2023 · 7 comments · Fixed by #48904
Closed

Press Esc twice to deselect all blocks #47172

jasmussen opened this issue Jan 16, 2023 · 7 comments · Fixed by #48904
Assignees
Labels
[Feature] Writing Flow Block selection, navigation, splitting, merging, deletion... [Package] Keyboard Shortcuts /packages/keyboard-shortcuts [Type] Enhancement A suggestion for improvement.

Comments

@jasmussen
Copy link
Contributor

Deselecting blocks is an important aspect of previewing your content. Right now it's not as simple as it should be — clicking a blank space in the canvas, or clicking in the breadcrumbs. See also #36535.

In many editors, pressing the Escape key deselects. In the block editor, this currently invokes "select mode", which makes blocks quick to navigate using the keyboard, easy to delete, and invokes "clickthrough" for nested blocks. Pressing Escape again does deselect blocks, but it stays in select mode, which causes a scroll-jump, shown in this GIF:

Pressing escape twice to open select mode

Furthermore, it isn't entirely clear how to exit select mode (which you do by clicking a block twice, or clicking a block and pressing Enter).

Should pressing Escape twice deselect blocks, and return to edit mode? It would make sense, since edit mode is the default mode after all, so the second keypress would essentially work as a "select the default editing tool". I suspect this would greatly improve the writing flow, and bring back the escape hatch / reset feel of pressing Escape.

@jasmussen jasmussen added [Type] Enhancement A suggestion for improvement. [Feature] Writing Flow Block selection, navigation, splitting, merging, deletion... [Package] Keyboard Shortcuts /packages/keyboard-shortcuts labels Jan 16, 2023
@andrewserong
Copy link
Contributor

andrewserong commented Mar 7, 2023

Just cross posting a comment from #48708 (comment) for visibility — what if instead of having to press Escape twice to trigger deselection we tried something like the following:

  • Within the editor canvas, if multiple blocks are selected and a user presses Escape, de-select the whole selection
  • To switch to Select mode when the Escape key is pressed, this will only happen if multiple blocks are not selected
  • If Select mode is active and block(s) are selected, then pressing Escape again will deselect all blocks

With the above, we'd still have the press Escape twice to deselect behaviour when only a single block is selected in the editor canvas, but also make it quicker to deselect when a user is already working with a selection. Would that make it easier, or does it just over complicate things? 🤔

@jasmussen
Copy link
Contributor Author

Within the editor canvas, if multiple blocks are selected and a user presses Escape, de-select the whole selection
To switch to Select mode when the Escape key is pressed, this will only happen if multiple blocks are not selected

That sounds pretty good to me, let's try it!

I would add that we can explore as an addon, depending on necessity, to have Esc when in select mode fall back to Edit mode, essentially making Esc a toggle. Still adherent to the above heuristic.

@andrewserong
Copy link
Contributor

Thanks for confirming! I'll have a play and see how difficult it is / how it might work. Will ping when I have a PR ready!

@andrewserong
Copy link
Contributor

I've opened up a PR to explore allowing Escape to deselect a multiselection over in #48904. It was pretty easy to add the behaviour back in, but I think we might want to get some feedback from @ellatrix on the approach, as from the looks of it, allowing Escape to switch to Navigation mode during a multiselection might have been an intentional feature.

From my perspective, allowing Escape to deselect both the block and range selection is a bit more intuitive, but I'm not a big user of navigation mode, so keen to hear what others think, too.

@joedolson
Copy link
Contributor

Assuming that focus is handled when deselecting, this would also enable us to close out #5524. Would love to get some of those old a11y issues closed out!

@shaunandrews
Copy link
Contributor

I'd really love to have a single press of esc deselect any selected blocks. Perhaps double-pressing esc could trigger Select mode, or we could think about a different key (or key combination) entirely; I'm not sure why Select mode was mapped to the esc in the first place.

@andrewserong
Copy link
Contributor

I've given #48904 a rebase, so that it now returns the user to the beginning of the selection when clearing a multi-selection by pressing Escape. Ready for testing! 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Writing Flow Block selection, navigation, splitting, merging, deletion... [Package] Keyboard Shortcuts /packages/keyboard-shortcuts [Type] Enhancement A suggestion for improvement.
Projects
Status: Done
5 participants