Skip to content

Commit 21605e7

Browse files
authored
[fix]: Hitting escape once should close alert dialog (#34382)
1 parent bfd2a6e commit 21605e7

3 files changed

Lines changed: 8 additions & 21 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": "[fix]: Hitting escape once should close alert dialog",
4+
"packageName": "@fluentui/web-components",
5+
"email": "jes@microsoft.com",
6+
"dependentChangeType": "patch"
7+
}

packages/web-components/src/dialog/dialog.spec.ts

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -154,26 +154,6 @@ test.describe('Dialog', () => {
154154
await expect(content).toBeVisible();
155155
});
156156

157-
test('should NOT close after the escape key is pressed when its `type` attribute is set to "alert"', async ({
158-
fastPage,
159-
page,
160-
}) => {
161-
const { element } = fastPage;
162-
const content = element.locator('#content');
163-
164-
await fastPage.setTemplate({ attributes: { type: 'alert' } });
165-
166-
await element.evaluate((node: Dialog) => {
167-
node.show();
168-
});
169-
170-
await expect(content).toBeVisible();
171-
172-
await page.keyboard.press('Escape');
173-
174-
await expect(content).toBeVisible();
175-
});
176-
177157
test('should set the `role` attribute to "dialog" on the internal dialog element when the `type` attribute is set to "dialog"', async ({
178158
fastPage,
179159
}) => {

packages/web-components/src/dialog/dialog.template.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export const template: ElementViewTemplate<Dialog> = html`
1717
aria-labelledby="${x => x.ariaLabelledby}"
1818
aria-label="${x => x.ariaLabel}"
1919
@click="${(x, c) => x.clickHandler(c.event as MouseEvent)}"
20-
@cancel="${(x, c) => (x.type === DialogType.alert ? c.event.preventDefault() : x.hide())}"
20+
@cancel="${x => x.hide()}"
2121
${ref('dialog')}
2222
>
2323
<slot></slot>

0 commit comments

Comments
 (0)