Skip to content
This repository was archived by the owner on Mar 4, 2020. It is now read-only.

fix(Toolbar): ToolbarMenuItem doesn't focus menu trigger element after 'onClick' was executed #2367

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
- Fix `loader` - adding labeling when loader get focus @kolaps33 ([#2352](https://github.com/microsoft/fluent-ui-react/pull/2352))
- `setWhatInputSource()` changes DOM attribute in `whatInput` @layershifter ([#2359](https://github.com/microsoft/fluent-ui-react/pull/2359))
- Styles from `Provider` are applied to components that rendered out of it in DOM @layershifter ([#2192](https://github.com/microsoft/fluent-ui-react/pull/2192))
- Fix `Toolbar` - ToolbarMenuItem doesn't focus menu trigger element after 'onClick' was executed ([#2367](https://github.com/microsoft/fluent-ui-react/pull/2367))

### Features
- Added sourcemaps to the dist output to simplify debugging @miroslavstastny ([#2329](https://github.com/microsoft/fluent-ui-react/pull/2329))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const doList = [
`aria-labelledby` props). Refer to{' '}
{link('toolbar(role)', 'https://www.w3.org/WAI/PF/aria/roles#toolbar')} for details.
</Text>,
'If `Toolbar` contains menu, the menu closes after clicking on one of the menu items. To prevent losing focus, move it manually in the `onClick` handler.',
]

const ToolbarBestPractices: React.FunctionComponent<{}> = () => {
Expand Down
4 changes: 0 additions & 4 deletions packages/react/src/components/Toolbar/ToolbarItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -190,9 +190,6 @@ class ToolbarItem extends UIComponent<WithAsProp<ToolbarItemProps>> {
}
// TODO: should we pass toolbarMenuItem to the user callback so he can decide if he wants to close the menu?
this.trySetMenuOpen(menuOpen, e)
if (!menuOpen) {
_.invoke(this.itemRef.current, 'focus')
}
},
variables: mergeComponentVariables(variables, predefinedProps.variables),
})
Expand Down Expand Up @@ -322,7 +319,6 @@ class ToolbarItem extends UIComponent<WithAsProp<ToolbarItemProps>> {
if (menu) {
if (doesNodeContainClick(this.menuRef.current, e, this.context.target)) {
this.trySetMenuOpen(false, e)
_.invoke(this.itemRef.current, 'focus')
}
}
}
Expand Down