mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
@@ -562,8 +562,22 @@ export class Select implements ComponentInterface {
|
||||
}
|
||||
|
||||
private async openAlert() {
|
||||
const label = this.getLabel();
|
||||
const labelText = label ? label.textContent : null;
|
||||
/**
|
||||
* TODO FW-3194
|
||||
* Remove legacyFormController logic.
|
||||
* Remove label and labelText vars
|
||||
* Pass `this.label` instead of `labelText`
|
||||
* when setting the header.
|
||||
*/
|
||||
let label: HTMLElement | null;
|
||||
let labelText: string | null | undefined;
|
||||
|
||||
if (this.legacyFormController.hasLegacyControl()) {
|
||||
label = this.getLabel();
|
||||
labelText = label ? label.textContent : null;
|
||||
} else {
|
||||
labelText = this.label;
|
||||
}
|
||||
|
||||
const interfaceOptions = this.interfaceOptions;
|
||||
const inputType = this.multiple ? 'checkbox' : 'radio';
|
||||
@@ -622,6 +636,7 @@ export class Select implements ComponentInterface {
|
||||
return this.overlay.dismiss();
|
||||
}
|
||||
|
||||
// TODO FW-3194 Remove this
|
||||
private getLabel() {
|
||||
return findItemLabel(this.el);
|
||||
}
|
||||
|
||||
@@ -248,3 +248,25 @@ test.describe('select: label', () => {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
test.describe('select: alert label', () => {
|
||||
test('should use the label to set the default header in an alert', async ({ page, skip }) => {
|
||||
skip.rtl();
|
||||
skip.mode('md');
|
||||
|
||||
await page.setContent(`
|
||||
<ion-select label="My Alert" interface="alert">
|
||||
<ion-select-option value="a">A</ion-select-option>
|
||||
</ion-select>
|
||||
`);
|
||||
|
||||
const select = page.locator('ion-select');
|
||||
const alert = page.locator('ion-alert');
|
||||
const ionAlertDidPresent = await page.spyOnEvent('ionAlertDidPresent');
|
||||
|
||||
await select.click();
|
||||
await ionAlertDidPresent.next();
|
||||
|
||||
await expect(alert.locator('.alert-title')).toHaveText('My Alert');
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user