Skip to content

Commit f0457b5

Browse files
Fix: Add support for overflow button in desktop callwithchat (#2748)
1 parent fbc4efb commit f0457b5

5 files changed

Lines changed: 65 additions & 26 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": "Add support for overflow button in desktop callwithchat",
4+
"packageName": "@azure/communication-react",
5+
"email": "2684369+JamesBurnside@users.noreply.github.com",
6+
"dependentChangeType": "patch"
7+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "prerelease",
3+
"comment": "Add support for overflow button in desktop callwithchat",
4+
"packageName": "@azure/communication-react",
5+
"email": "2684369+JamesBurnside@users.noreply.github.com",
6+
"dependentChangeType": "patch"
7+
}

packages/react-composites/src/composites/CallWithChatComposite/CallWithChatControlBar.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,8 @@ export const CallWithChatControlBar = (props: CallWithChatControlBarProps & Cont
241241
disableButtonsForHoldScreen={props.disableButtonsForHoldScreen}
242242
styles={commonButtonStyles}
243243
onClickShowDialpad={props.onClickShowDialpad}
244+
/* @conditional-compile-remove(control-bar-button-injection) */
245+
callControls={props.callControls}
244246
/>
245247
)
246248
}

packages/react-composites/src/composites/CallWithChatComposite/CustomButton.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ export const generateCustomCallWithChatDrawerButtons = (
9898
id: buttonProps.id,
9999
iconProps: { iconName: buttonProps.iconName },
100100
itemKey: buttonProps.key ?? `${buttonProps.placement}_${i}`,
101+
key: buttonProps.key ?? `${buttonProps.placement}_${i}`,
101102
onItemClick: buttonProps.onItemClick,
102103
text: buttonProps.text
103104
}))}

packages/react-composites/src/composites/CallWithChatComposite/components/DesktopMoreButton.tsx

Lines changed: 48 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,17 @@ import { buttonFlyoutIncreasedSizeStyles } from '../../CallComposite/styles/Butt
1515
import { MoreButton } from '../../common/MoreButton';
1616
/*@conditional-compile-remove(PSTN-calls) */ /* @conditional-compile-remove(one-to-n-calling) */
1717
import { useLocale } from '../../localization';
18+
/* @conditional-compile-remove(control-bar-button-injection) */
19+
import { CallWithChatControlOptions } from '../CallWithChatComposite';
20+
/* @conditional-compile-remove(control-bar-button-injection) */
21+
import { generateCustomCallWithChatDrawerButtons, onFetchCustomButtonPropsTrampoline } from '../CustomButton';
1822

1923
/** @private */
2024
export interface DesktopMoreButtonProps extends ControlBarButtonProps {
2125
disableButtonsForHoldScreen?: boolean;
2226
onClickShowDialpad?: () => void;
27+
/* @conditional-compile-remove(control-bar-button-injection) */
28+
callControls?: boolean | CallWithChatControlOptions;
2329
}
2430

2531
/**
@@ -41,41 +47,57 @@ export const DesktopMoreButton = (props: DesktopMoreButtonProps): JSX.Element =>
4147
[localeStrings]
4248
);
4349

44-
const moreButtonContextualMenuItems = (): IContextualMenuItem[] => {
45-
const items: IContextualMenuItem[] = [];
50+
const moreButtonContextualMenuItems: IContextualMenuItem[] = [];
4651

47-
/*@conditional-compile-remove(PSTN-calls) */ /* @conditional-compile-remove(one-to-n-calling) */
48-
items.push({
49-
key: 'holdButtonKey',
50-
text: localeStrings.component.strings.holdButton.tooltipOffContent,
52+
/*@conditional-compile-remove(PSTN-calls) */ /* @conditional-compile-remove(one-to-n-calling) */
53+
moreButtonContextualMenuItems.push({
54+
key: 'holdButtonKey',
55+
text: localeStrings.component.strings.holdButton.tooltipOffContent,
56+
onClick: () => {
57+
holdButtonProps.onToggleHold();
58+
},
59+
iconProps: { iconName: 'HoldCallContextualMenuItem', styles: { root: { lineHeight: 0 } } },
60+
itemProps: {
61+
styles: buttonFlyoutIncreasedSizeStyles
62+
},
63+
disabled: props.disableButtonsForHoldScreen
64+
});
65+
66+
/*@conditional-compile-remove(PSTN-calls) */
67+
if (props.onClickShowDialpad) {
68+
moreButtonContextualMenuItems.push({
69+
key: 'showDialpadKey',
70+
text: localeStrings.strings.callWithChat.openDtmfDialpadLabel,
5171
onClick: () => {
52-
holdButtonProps.onToggleHold();
72+
props.onClickShowDialpad && props.onClickShowDialpad();
5373
},
54-
iconProps: { iconName: 'HoldCallContextualMenuItem', styles: { root: { lineHeight: 0 } } },
74+
iconProps: { iconName: 'Dialpad', styles: { root: { lineHeight: 0 } } },
5575
itemProps: {
5676
styles: buttonFlyoutIncreasedSizeStyles
5777
},
5878
disabled: props.disableButtonsForHoldScreen
5979
});
80+
}
6081

61-
/*@conditional-compile-remove(PSTN-calls) */
62-
if (props.onClickShowDialpad) {
63-
items.push({
64-
key: 'showDialpadKey',
65-
text: localeStrings.strings.callWithChat.openDtmfDialpadLabel,
66-
onClick: () => {
67-
props.onClickShowDialpad && props.onClickShowDialpad();
68-
},
69-
iconProps: { iconName: 'Dialpad', styles: { root: { lineHeight: 0 } } },
70-
itemProps: {
71-
styles: buttonFlyoutIncreasedSizeStyles
72-
},
73-
disabled: props.disableButtonsForHoldScreen
74-
});
75-
}
82+
/* @conditional-compile-remove(control-bar-button-injection) */
83+
const customDrawerButtons = useMemo(
84+
() =>
85+
generateCustomCallWithChatDrawerButtons(
86+
onFetchCustomButtonPropsTrampoline(typeof props.callControls === 'object' ? props.callControls : undefined),
87+
typeof props.callControls === 'object' ? props.callControls.displayType : undefined
88+
),
89+
[props.callControls]
90+
);
7691

77-
return items;
78-
};
92+
/* @conditional-compile-remove(control-bar-button-injection) */
93+
customDrawerButtons['overflow']?.props.children.forEach((element) => {
94+
moreButtonContextualMenuItems.push({
95+
itemProps: {
96+
styles: buttonFlyoutIncreasedSizeStyles
97+
},
98+
...element
99+
});
100+
});
79101

80102
return (
81103
<MoreButton
@@ -84,7 +106,7 @@ export const DesktopMoreButton = (props: DesktopMoreButtonProps): JSX.Element =>
84106
/*@conditional-compile-remove(PSTN-calls) */ /* @conditional-compile-remove(one-to-n-calling) */
85107
strings={moreButtonStrings}
86108
menuIconProps={{ hidden: true }}
87-
menuProps={{ items: moreButtonContextualMenuItems() }}
109+
menuProps={{ items: moreButtonContextualMenuItems }}
88110
/>
89111
);
90112
};

0 commit comments

Comments
 (0)