Skip to content

Commit 1768210

Browse files
prprabhu-mspull[bot]
authored andcommitted
Prevent dismissal of ContextMenu on window resize (#1138)
1 parent c5e0e1b commit 1768210

3 files changed

Lines changed: 56 additions & 10 deletions

File tree

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "prerelease",
3+
"comment": "Do not dismiss ParticipantsButtton and DevicesButton Callout on resize events",
4+
"packageName": "@internal/react-components",
5+
"email": "82062616+prprabhu-ms@users.noreply.github.com",
6+
"dependentChangeType": "patch"
7+
}

packages/react-components/src/components/DevicesButton.tsx

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -172,12 +172,29 @@ const generateDefaultMenuProps = (
172172

173173
const defaultMenuProps: IContextualMenuProps = {
174174
items: [],
175-
176175
styles: props.styles?.menuStyles,
177-
178-
// Confine the menu to the parents bounds.
179-
// More info: https://github.com/microsoft/fluentui/issues/18835
180-
calloutProps: { styles: { root: { maxWidth: '95%' } } }
176+
calloutProps: {
177+
styles: {
178+
root: {
179+
// Confine the menu to the parents bounds.
180+
// More info: https://github.com/microsoft/fluentui/issues/18835
181+
// NB: 95% to keep some space for margin, drop shadow etc around the Callout.
182+
maxWidth: '95%'
183+
}
184+
},
185+
// Disable dismiss on resize to work around a couple Fluent UI bugs
186+
// - The Callout is dismissed whenever *any child of window (inclusive)* is resized. In practice, this
187+
// happens when we change the VideoGallery layout, or even when the video stream element is internally resized
188+
// by the headless SDK.
189+
// - There is a `preventDismissOnEvent` prop that we could theoretically use to only dismiss when the target of
190+
// of the 'resize' event is the window itself. But experimentation shows that setting that prop doesn't
191+
// deterministically avoid dismissal.
192+
//
193+
// A side effect of this workaround is that the context menu stays open when window is resized, and may
194+
// get detached from original target visually. That bug is preferable to the bug when this value is not set -
195+
// The Callout (frequently) gets dismissed automatically.
196+
preventDismissOnResize: true
197+
}
181198
};
182199

183200
const menuItemStyles = merge(buttonFlyoutItemStyles, props.styles?.menuStyles?.menuItemStyles ?? {});

packages/react-components/src/components/ParticipantsButton.tsx

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,21 @@ export const ParticipantsButton = (props: ParticipantsButtonProps): JSX.Element
255255
const menuProps: IContextualMenuProps = {
256256
title: strings.menuHeader,
257257
styles: merge(participantsButtonMenuPropsStyle, styles?.menuStyles),
258-
items: []
258+
items: [],
259+
calloutProps: {
260+
// Disable dismiss on resize to work around a couple Fluent UI bugs
261+
// - The Callout is dismissed whenever *any child of window (inclusive)* is resized. In practice, this
262+
// happens when we change the VideoGallery layout, or even when the video stream element is internally resized
263+
// by the headless SDK.
264+
// - There is a `preventDismissOnEvent` prop that we could theoretically use to only dismiss when the target of
265+
// of the 'resize' event is the window itself. But experimentation shows that setting that prop doesn't
266+
// deterministically avoid dismissal.
267+
//
268+
// A side effect of this workaround is that the context menu stays open when window is resized, and may
269+
// get detached from original target visually. That bug is preferable to the bug when this value is not set -
270+
// The Callout (frequently) gets dismissed automatically.
271+
preventDismissOnResize: true
272+
}
259273
};
260274

261275
if (participantCount > 0) {
@@ -273,10 +287,18 @@ export const ParticipantsButton = (props: ParticipantsButtonProps): JSX.Element
273287
iconProps: { iconName: 'People' },
274288
subMenuProps: {
275289
items: generateDefaultParticipantsSubMenuProps(),
276-
277-
// Confine the menu to the parents bounds.
278-
// More info: https://github.com/microsoft/fluentui/issues/18835
279-
calloutProps: { styles: { root: { maxWidth: '100%' } } }
290+
calloutProps: {
291+
styles: {
292+
root: {
293+
// Confine the menu to the parents bounds.
294+
// More info: https://github.com/microsoft/fluentui/issues/18835
295+
maxWidth: '100%'
296+
}
297+
},
298+
// Disable dismiss on resize to work around a couple Fluent UI bugs
299+
// See reasoning in the props for the parent menu.
300+
preventDismissOnResize: true
301+
}
280302
},
281303
'data-ui-id': ids.participantButtonPeopleMenuItem
282304
});

0 commit comments

Comments
 (0)