-
Notifications
You must be signed in to change notification settings - Fork 2.9k
"BaseButton: Add onFocusCapture to the split button container to focus the container instead of doing it in the menu onClick #5934
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"BaseButton: Add onFocusCapture to the split button container to focus the container instead of doing it in the menu onClick #5934
Conversation
| private _onToggleMenu = (shouldFocusOnContainer: boolean): void => { | ||
| if (this._splitButtonContainer.current) { | ||
| this._splitButtonContainer.current.focus(); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this the right fix? It looks like you added it in March to fix some specific issues: #4222
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
…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
|
@jspurlin Yes, I'll edit the validation to be more clear. |
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