Skip to content

Commit debdb33

Browse files
Custom Button Injection auto dismiss drawer menu when actioned (#5855)
* Add custom button injection autohide in drawermenus * Change files * Resolve linter fixes * Simplify condition
1 parent 3234740 commit debdb33

6 files changed

Lines changed: 32 additions & 0 deletions

File tree

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"type": "prerelease",
3+
"area": "improvement",
4+
"workstream": "CustomButtonInjection",
5+
"comment": "Add custom button injection autohide in drawermenus",
6+
"packageName": "@azure/communication-react",
7+
"email": "edwardlee@microsoft.com",
8+
"dependentChangeType": "patch"
9+
}

packages/communication-react/review/beta/communication-react.api.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2901,6 +2901,7 @@ export type CustomCallControlButtonPlacement = 'primary' | 'overflow' | 'seconda
29012901
// @public
29022902
export interface CustomCallControlButtonProps {
29032903
disabled?: boolean;
2904+
dismissDrawer?: boolean;
29042905
iconName?: string;
29052906
id?: string;
29062907
onItemClick?: () => void;

packages/communication-react/review/stable/communication-react.api.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2646,6 +2646,7 @@ export type CustomCallControlButtonPlacement = 'primary' | 'overflow' | 'seconda
26462646
// @public
26472647
export interface CustomCallControlButtonProps {
26482648
disabled?: boolean;
2649+
dismissDrawer?: boolean;
26492650
iconName?: string;
26502651
id?: string;
26512652
onItemClick?: () => void;

packages/react-components/src/components/Drawer/DrawerMenuItem.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@ export interface _DrawerMenuItemProps {
6262
* Aria label for the menu item
6363
*/
6464
ariaLabel?: string;
65+
/**
66+
* Dismiss the drawer menu when the button is clicked
67+
*/
68+
dismissDrawer?: boolean;
6569
}
6670

6771
/**

packages/react-composites/src/composites/common/ControlBar/CustomButton.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,12 @@ export interface CustomCallControlButtonProps {
8383
* Optional strings to override in component
8484
*/
8585
strings?: CustomCallControlButtonStrings;
86+
/**
87+
* Dismiss the drawer menu when the button is clicked
88+
*
89+
* @defaultValue true
90+
*/
91+
dismissDrawer?: boolean;
8692
}
8793

8894
/**

packages/react-composites/src/composites/common/Drawer/MoreDrawer.tsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -696,6 +696,17 @@ export const MoreDrawer = (props: MoreDrawerProps): JSX.Element => {
696696
drawerMenuItems.push(element);
697697
});
698698
customDrawerButtons['overflow'].forEach((element) => {
699+
const customButtonProps = { ...element };
700+
// Default Auto dismiss drawer on click unless specified
701+
if (customButtonProps.dismissDrawer !== false) {
702+
element = {
703+
...customButtonProps,
704+
onItemClick: () => {
705+
customButtonProps.onItemClick?.();
706+
onLightDismiss();
707+
}
708+
};
709+
}
699710
drawerMenuItems.push(element);
700711
});
701712
return (

0 commit comments

Comments
 (0)