Repository navigation
Menu bar cleanup and focus improvements - #1092
Merged
Merged
Conversation
Clarify docs
joshaber
suggested changes
Mar 29, 2017
joshaber
left a comment
Contributor
There was a problem hiding this comment.
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.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| readonly foldoutState: AppMenuFoldout | null | ||
|
|
||
| /** | ||
| * An optional function that's called when the menubar looses focus. |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| // 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.
This comment was marked as spam.
Sorry, something went wrong.
Member
Author
|
🐨 |
joshaber
approved these changes
Mar 29, 2017
| 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.
Sorry, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.
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.
See how the focus returns to the text box when I close the menu.