Skip to content

Menu bar cleanup and focus improvements - #1092

Merged
joshaber merged 30 commits into
masterfrom
menu-bar-cleanup-and-focus-improvements
Mar 29, 2017
Merged

joshaber merged 30 commits into
masterfrom
menu-bar-cleanup-and-focus-improvements

Conversation

@niik

@niik niik commented Mar 29, 2017

Copy link
Copy Markdown
Member

This work is being done in preparation for conditionally showing the menu bar in full screen mode when pressing Alt.

At a high level this moves us from using keyboard focus as an implicit state governing the behavior of the menu bar to using the foldout state as the only indicator as to whether the menu bar is active or not.

This also implements one flow that I did not take into account in #991, namely hitting Alt in order to focus on the first menu item and then hitting an access key for any of the top level menu items to select it.

menubar-top-level-access-key

Additionally this implements focus yielding (for lack of a better term). Well-behaved native menu bars on Windows will yield back focus to the component which last had focus when closed by, for example, hitting Escape. Technically speaking they don't yield, they never steal focus to begin with as they operate outside of the keyboard focus scope of the app but we're not able to do that so this is the next-best-thing.

menubar-focus-yield

See how the focus returns to the text box when I close the menu.

@joshaber joshaber self-assigned this Mar 29, 2017

@joshaber joshaber left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a couple 💅. Otherwise a nice clean up.

this.props.onKeyDown(this.props.menuItem, event)

if (!this.isMenuOpen && !event.defaultPrevented) {
// Hitting Escape while focused on the menu button (while the menu

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

Comment thread app/src/ui/app-menu/app-menu-bar.tsx Outdated
readonly foldoutState: AppMenuFoldout | null

/**
* An optional function that's called when the menubar looses focus.

This comment was marked as spam.

// Us having a reference to the previously focused element doesn't
// necessarily mean that that element is still in the DOM so we explicitly
// check to see if it is before we yield focus to it.
if (this.stolenFocusElement && document.contains(this.stolenFocusElement)) {

This comment was marked as spam.

@niik

niik commented Mar 29, 2017

Copy link
Copy Markdown
Member Author

🐨

this.props.onKeyDown(this.props.menuItem, event)

if (!this.isMenuOpen && !event.defaultPrevented) {
// Hitting Escape while focused on the menu button (while the menu

This comment was marked as spam.

@joshaber
joshaber merged commit 32bcecb into master Mar 29, 2017
@joshaber
joshaber deleted the menu-bar-cleanup-and-focus-improvements branch March 29, 2017 20:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants