Skip to content

Commit 8c74438

Browse files
authored
Callwithchat mobile: dismissed drawer after device selection (#2115)
* fix drawer bug' * Change files * update ui test * update ui test * update pr
1 parent 4b9be0a commit 8c74438

3 files changed

Lines changed: 23 additions & 5 deletions

File tree

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "patch",
3+
"comment": "Fixed bug where drawer on mobile does not get dismissed after making a selection",
4+
"packageName": "@internal/react-composites",
5+
"email": "carolinecao@microsoft.com",
6+
"dependentChangeType": "patch"
7+
}

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ const inferCallWithChatControlOptions = (
9898
export const MoreDrawer = (props: MoreDrawerProps): JSX.Element => {
9999
const drawerMenuItems: DrawerMenuItemProps[] = [];
100100

101-
const { speakers, onSelectSpeaker } = props;
101+
const { speakers, onSelectSpeaker, onLightDismiss } = props;
102102
const onSpeakerItemClick = useCallback(
103103
(_ev, itemKey) => {
104104
const selected = speakers?.find((speaker) => speaker.id === itemKey);
@@ -107,8 +107,9 @@ export const MoreDrawer = (props: MoreDrawerProps): JSX.Element => {
107107
// But this is a known issue in our state.
108108
onSelectSpeaker(selected as AudioDeviceInfo);
109109
}
110+
onLightDismiss();
110111
},
111-
[speakers, onSelectSpeaker]
112+
[speakers, onSelectSpeaker, onLightDismiss]
112113
);
113114

114115
const drawerSelectionOptions = inferCallWithChatControlOptions(props.callControls);
@@ -142,8 +143,9 @@ export const MoreDrawer = (props: MoreDrawerProps): JSX.Element => {
142143
// But this is a known issue in our state.
143144
onSelectMicrophone(selected as AudioDeviceInfo);
144145
}
146+
onLightDismiss();
145147
},
146-
[microphones, onSelectMicrophone]
148+
[microphones, onSelectMicrophone, onLightDismiss]
147149
);
148150

149151
if (props.microphones && props.microphones.length > 0) {

packages/react-composites/tests/browser/callwithchat/CallWithChatComposite.test.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,11 @@ test.describe('CallWithChat Composite CallWithChat Page Tests', () => {
160160
await moreDrawerSpeakerDiv?.click();
161161
const submenuNewAudioDeviceDiv = await page.$('div[role="menu"] >> text="Fake Audio Output 1"');
162162
await submenuNewAudioDeviceDiv?.click();
163+
//need to open again because submenu is dismissed automatically after selection
164+
await pageClick(page, dataUiId('call-with-chat-composite-more-button'));
165+
const moreDrawerSpeakerDiv_copy = await page.$('div[role="menu"] >> text=Speaker');
166+
await moreDrawerSpeakerDiv_copy?.click();
167+
await page.$('div[role="menu"] >> text="Fake Audio Output 1"');
163168
expect(await stableScreenshot(page)).toMatchSnapshot(`call-with-chat-more-drawer-submenu-speaker-select.png`);
164169
}
165170
});
@@ -177,7 +182,6 @@ test.describe('CallWithChat Composite CallWithChat Page Tests', () => {
177182
await submenuNewAudioDeviceDiv?.click();
178183

179184
// Display MoreDrawer to view newly selected audio device
180-
await page.mouse.click(100, 100);
181185
await pageClick(page, dataUiId('call-with-chat-composite-more-button'));
182186
expect(await stableScreenshot(page)).toMatchSnapshot(
183187
`call-with-chat-more-drawer-new-selected-speaker-screen.png`
@@ -203,6 +207,12 @@ test.describe('CallWithChat Composite CallWithChat Page Tests', () => {
203207
await moreDrawerMicrophoneDiv?.click();
204208
const submenuNewAudioDeviceDiv = await page.$('div[role="menu"] >> text="Fake Audio Input 1"');
205209
await submenuNewAudioDeviceDiv?.click();
210+
211+
//need to open again because submenu is dismissed automatically after selection
212+
await pageClick(page, dataUiId('call-with-chat-composite-more-button'));
213+
const moreDrawerMicrophoneDiv_copy = await page.$('div[role="menu"] >> text=Microphone');
214+
await moreDrawerMicrophoneDiv_copy?.click();
215+
await page.$('div[role="menu"] >> text="Fake Audio Input 1"');
206216
expect(await stableScreenshot(page)).toMatchSnapshot(`call-with-chat-more-drawer-submenu-microphone-select.png`);
207217
}
208218
});
@@ -220,7 +230,6 @@ test.describe('CallWithChat Composite CallWithChat Page Tests', () => {
220230
await submenuNewAudioDeviceDiv?.click();
221231

222232
// Display MoreDrawer to view newly selected audio device
223-
await page.mouse.click(100, 100);
224233
await pageClick(page, dataUiId('call-with-chat-composite-more-button'));
225234
expect(await stableScreenshot(page)).toMatchSnapshot(
226235
`call-with-chat-more-drawer-new-selected-microphone-screen.png`

0 commit comments

Comments
 (0)