Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion core/src/components/select/select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ export class Select implements ComponentInterface {
}

private setValue(value?: any | null) {
if (this.isValueEqual(this.value, value)) {
if (this.disabled || this.isValueEqual(this.value, value)) {
return;
}
this.value = value;
Expand Down
24 changes: 24 additions & 0 deletions core/src/components/select/test/select.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,30 @@ describe('ion-select: overlay option labels', () => {
jest.restoreAllMocks();
});

it('should ignore a selection when disabled after opening', async () => {
const createAlert = stubAlertController();
const page = await newSpecPage({
components: [Select, SelectOption],
html: `<ion-select value="apple">
<ion-select-option value="apple">Apple</ion-select-option>
<ion-select-option value="orange">Orange</ion-select-option>
</ion-select>`,
});
const select = page.body.querySelector('ion-select')!;
const onChange = jest.fn();
select.addEventListener('ionChange', onChange);
await select.open();
const { buttons } = createAlert.mock.calls[0][0];

select.disabled = true;
await page.waitForChanges();
(buttons![1] as any).handler('orange');
await page.waitForChanges();

expect(select.value).toBe('apple');
expect(onChange).not.toHaveBeenCalled();
});

it('should label alert inputs with the text the option renders', async () => {
const createAlert = stubAlertController();

Expand Down
Loading