Skip to content

Commit 70d2784

Browse files
authored
fix(select): avoid duplicate dialogs and backdrops when clicking (#25175)
Resolves #25126
1 parent ff1429b commit 70d2784

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

core/src/components/select/select.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,8 +188,8 @@ export class Select implements ComponentInterface {
188188
if (this.disabled || this.isExpanded) {
189189
return undefined;
190190
}
191-
const overlay = (this.overlay = await this.createOverlay(event));
192191
this.isExpanded = true;
192+
const overlay = (this.overlay = await this.createOverlay(event));
193193
overlay.onDidDismiss().then(() => {
194194
this.overlay = undefined;
195195
this.isExpanded = false;
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import { expect } from '@playwright/test';
2+
import { test } from '@utils/test/playwright';
3+
4+
test.describe('select: basic', () => {
5+
test('should not open multiple alert windows when clicked multiple times', async ({ page }) => {
6+
test.info().annotations.push({
7+
type: 'issue',
8+
description: 'https://github.com/ionic-team/ionic-framework/issues/25126',
9+
});
10+
11+
await page.goto('/src/components/select/test/basic');
12+
13+
const select = page.locator('#gender');
14+
15+
await select.evaluate((el: HTMLSelectElement) => {
16+
/*
17+
* Playwright's click() method attempts to scroll to the handle
18+
* to perform the action. That is problematic when the overlay
19+
* is already visible. We manually click() the element instead
20+
* to avoid flaky tests.
21+
*/
22+
el.click();
23+
el.click();
24+
el.click();
25+
});
26+
27+
const alerts = await page.$$('ion-alert');
28+
29+
expect(alerts.length).toBe(1);
30+
});
31+
});

0 commit comments

Comments
 (0)