"BaseButton: Add onFocusCapture to the split button container to focus the container instead of doing it in the menu onClick#5934
Merged
chang47 merged 17 commits intomicrosoft:masterfrom Aug 20, 2018
Conversation
added 9 commits
May 7, 2018 19:02
jspurlin
reviewed
Aug 15, 2018
| private _onToggleMenu = (shouldFocusOnContainer: boolean): void => { | ||
| if (this._splitButtonContainer.current) { | ||
| this._splitButtonContainer.current.focus(); | ||
| } |
Contributor
There was a problem hiding this comment.
Is this the right fix? It looks like you added it in March to fix some specific issues: #4222
Contributor
Author
There was a problem hiding this comment.
Like we talked offline, we're getting rid of this and instead we're using the onFocus capture event to ensure that focus is set to the SplitButton Container instead of us manually putting it there.
added 3 commits
August 15, 2018 16:34
…an/stopAgressiveFocusInMenus
…om/chang47/office-ui-fabric-react into chiechan/stopAgressiveFocusInMenus
…extual menu: added onMenuDismissed to be after we focus the previous active element
… split button container
…it button container focus to the focus capture in the split container
Contributor
Contributor
Author
|
@jspurlin Yes, I'll edit the validation to be more clear. |
jspurlin
approved these changes
Aug 17, 2018
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Pull request checklist
$ npm run changeDescription of changes
In the past, we explicitly put focus on the SplitButtonContainer in BaseButton when we do a menu click, because we don't want to be able to focus each individual buttons in a split button.
However this created a problem with SplitButtons in the event where we want to return focus to the previous element when we open a menu and hit escape to close it.
Specifically what happens is that we:
As a result whenever we close the menu, focus will always return back to the split button container, which is great for all cases except for the one where we don't want this behavior.
To fix this without breaking existing behavior, I added a onFocusCapture event to the split button container and removed it from being able to be called when we hit the menu onclick event.
Through investigation, we found 2 keypoints with the out that a mouseDown event is that's important for this change:
Here's the behavior If we click on the menu button in a split button:
Now the case for where we don't want to put focus on the split button container:
By doing this, we get the new behavior we want where focus does not go back to the button and we still keep existing fabric behavior.
Focus areas to test
I've validated that in both buttons and split buttons:
In the case where we do a preventDefault() for the mouseDown event:
2. If the user opens a menu via a click and press escape, focus now goes back to wherever we were focusing on prior to clicking on the button.
Microsoft Reviewers: Open in CodeFlow