Skip to content
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

fix(Toolbar): close previous submenu when opening another submenu #24836

Merged
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 packages/fluentui/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
- Fix `FocusZone` to reset tabindex when focus is outside the zone with prop `shouldResetActiveElementWhenTabFromZone` @yuanboxue-amber ([#24463](https://github.com/microsoft/fluentui/pull/24463))
- Change `useLayoutEffect` in `Dropdown` to `useIsomorphicLayoutEffect` @marwan38 ([#24559](https://github.com/microsoft/fluentui/pull/24559))
- Fix styling mutation when merging themes in `Dropdown` @petrjaros ([#24787](https://github.com/microsoft/fluentui/pull/24787))
- Fix `Toolbar` submenu closing when another submenu is opened @miroslavstastny ([#24836](https://github.com/microsoft/fluentui/pull/24836))

### Performance
- Avoid memory trashing in `felaExpandCssShorthandsPlugin` @layershifter ([#24663](https://github.com/microsoft/fluentui/pull/24663))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ const config: ScreenerTestsConfig = {
builder
.click(`.${toolbarItemWrapperClassName} button`)
.snapshot('Shows menu')
.keys(`.${toolbarMenuItemClassName}:nth-child(1)`, keys.rightArrow)
.snapshot('Opens submenu'),
.keys(`.${toolbarMenuItemClassName}#ToolbarExampleMenuWithSubmenu_Play`, keys.rightArrow)
.snapshot('Opens first submenu')
.click(`.${toolbarMenuItemClassName}#ToolbarExampleMenuWithSubmenu_Appearance`)
.snapshot('Opens second submenu'),
],
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,21 @@ const ToolbarExampleMenuWithSubmenuShorthand = () => {
menu: [
{
key: 'play',
id: 'ToolbarExampleMenuWithSubmenu_Play',
content: 'Play',
icon: <PlayIcon />,
menu: {
items: ['Play with audio', { content: 'Play with video', key: 'playVideo', menu: ['HD', 'Full HD'] }],
},
},
{
key: 'appearance',
id: 'ToolbarExampleMenuWithSubmenu_Appearance',
content: 'Appearance',
menu: {
items: ['Centered Layout', 'Zen', 'Zoom In', 'Zoom Out'],
},
},
{ key: 'pause', content: 'Pause', icon: <PauseIcon /> },
{ key: 'divider', kind: 'divider' },
'Without icon',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,12 @@ export const ToolbarMenuItem = compose<'button', ToolbarMenuItemProps, ToolbarMe
</ToolbarVariablesProvider>
</Popper>
</Ref>
<EventListener listener={outsideClickHandler(getRefs)} target={context.target} type="click" />
<EventListener
capture={true}
listener={outsideClickHandler(getRefs)}
target={context.target}
type="click"
/>
</>
);
}}
Expand Down