Keep caret position / selection when switching Editor mode via the keyboard shortcut #16901
Labels
[Focus] Accessibility (a11y)
Changes that impact accessibility and need corresponding review (e.g. markup changes).
[Type] Enhancement
A suggestion for improvement.
#16874 fixed the focus management when switching between "Code Editor" or "Visual Editor" by activating the related items in the More menu.
However, when switching between "Code Editor" or "Visual Editor" using the related keyboard shortcut, there's a focus loss.
On a mac, the shortcut is: Shift Option Cmd M
On Windows, it's: Shift Ctrl Alt M
To reproduce:
Expecterd:
The caret insertion point or the current selection should be preserved.
If focus was on an element of a Block UI, focus should be restored there (visual) or at the beginning of the block source (code)
Worth noting a similar functionality was introduced a while ago for the Classic Editor. See https://core.trac.wordpress.org/changeset/42184 / https://core.trac.wordpress.org/ticket/42530
It still sort of works when activating the Classic Editor plugin. It appears to not work so well now. Seems to me HTML tags or Gutenberg comments (if any) prevents this feature to work correctly.
Regardless, it's a powerful feature for all keyboard users and saves time while editing a post. I'd like to propose to implement an equivalent feature in Gutenberg too.
It should work only when using the keyboard shortcut.
Instead, when using the related commands in the More menu, the behavior implemented in #16874 seems the most appropriate.
The text was updated successfully, but these errors were encountered: