Skip to content

Restore keyboard focus after invoking main menu via shortcuts - #7908

Merged
gtritchie merged 2 commits into
masterfrom
bugfix/menu-focus-using-keyboard
Sep 29, 2020
Merged

gtritchie merged 2 commits into
masterfrom
bugfix/menu-focus-using-keyboard

Conversation

@gtritchie

Copy link
Copy Markdown
Member

Intent

For a keyboard-only user (including screen reader users) it is very inconvenient that after invoking and using the RStudio Server main menu via keyboard shortcuts, keyboard focus is usually left on the page body or some other location unrelated to where it was when menu was invoked.

Behavior should be more like a desktop application, where once main menu is dismissed, focus returns to where it was before.

Approach

When Server main menu is opened via keyboard shortcuts, capture the current focus location. Detect if the one of the following happens to restore focus to that location:

  • a command is fired by picking an item from the menus OR by using a keyboard shortcut while the menus were displayed
  • user cancels out of the menus via ESC key (each expanded submenu requires an ESC press to close it, returning to its parent; when the main menu bar has a selection but no submenu displayed, another ESC is required to "close" it and return focus to the previous location)
  • user clicks outside the menus
  • an asteroid strikes the planet (ok, I don't actually handle that case)

If user hits the Tab or Shift+Tab keys while menus are open, we cancel the restore focus logic so they can then navigate through normal page tab order.

QA Notes

This new code is only invoked on RStudio Server, and only if the main menu is opened via the keyboard shortcuts. Using the menu entirely via mouse doesn't involve this code, and we don't currently attempt to restore focus for a mouse-only user (though we should, #7907).

@gtritchie gtritchie added this to the v1.4 milestone Sep 29, 2020
@gtritchie
gtritchie merged commit dbfee28 into master Sep 29, 2020
@gtritchie
gtritchie deleted the bugfix/menu-focus-using-keyboard branch April 6, 2021 21:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Keyboard invocation of main menu doesn't restore focus when menu closed

2 participants