feat(select): ionChange will only emit from user committed changes (#26066)

BREAKING CHANGE:

`ionChange` is no longer emitted when the `value` of `ion-select` is modified externally. `ionChange` is only emitted from user committed changes, such as confirming a selected option in the select's overlay.
This commit is contained in:
Liam DeBeasi
2022-10-10 08:36:51 -05:00
committed by GitHub
parent b052d3b262
commit 34c4137868
12 changed files with 153 additions and 24 deletions

View File

@@ -23,7 +23,7 @@
<ion-item>
<ion-label>Select</ion-label>
<ion-select [(ngModel)]="select">
<ion-select [(ngModel)]="select" id="game-console">
<ion-select-option value="">No Game Console</ion-select-option>
<ion-select-option value="nes">NES</ion-select-option>
<ion-select-option value="n64" selected>Nintendo64</ion-select-option>

View File

@@ -31,5 +31,8 @@
<ion-select-option [value]="1">Option 1</ion-select-option>
</ion-select>
</ion-item>
<ion-button id="set-to-null" (click)="setSelect(null)">Set select value to "null"></ion-button>
<ion-button id="set-to-undefined" (click)="setSelect(undefined)">Set select value to "undefined"></ion-button>
</form>
</ion-content>

View File

@@ -36,6 +36,10 @@ export class ModalExampleComponent implements OnInit, ViewWillLeave, ViewDidEnte
this.onInit++;
}
setSelect(value: null | undefined) {
this.form.get('select').setValue(value);
}
ionViewWillEnter() {
if (this.onInit !== 1) {
throw new Error('ngOnInit was not called');