mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-20 20:33:32 +08:00
feat(datetime): ionChange will only emit from user committed changes (#26083)
resolves #20873 resolves #24452 BREAKING CHANGE - `ionChange` is no longer emitted when the `value` property of `ion-datetime` is modified externally. `ionChange` is only emitted from user committed changes, such as clicking or tapping a date. - Datetime no longer automatically adjusts the `value` property when passed an array and `multiple="false"`. Developers should update their apps to ensure they are using the API correctly.
This commit is contained in:
@ -126,7 +126,7 @@ export class DatetimeButton implements ComponentInterface {
|
||||
* text in the buttons.
|
||||
*/
|
||||
this.setDateTimeText();
|
||||
addEventListener(datetimeEl, 'ionChange', this.setDateTimeText);
|
||||
addEventListener(datetimeEl, 'ionValueChange', this.setDateTimeText);
|
||||
|
||||
/**
|
||||
* Configure the initial selected button
|
||||
|
@ -73,12 +73,12 @@ test.describe('datetime-button: multiple selection', () => {
|
||||
await page.waitForSelector('.datetime-ready');
|
||||
|
||||
const datetime = page.locator('ion-datetime');
|
||||
const ionChange = await page.spyOnEvent('ionChange');
|
||||
const ionValueChange = await page.spyOnEvent('ionValueChange');
|
||||
const dateButton = page.locator('#date-button');
|
||||
await expect(dateButton).toHaveText('2 days');
|
||||
|
||||
await datetime.evaluate((el: HTMLIonDatetimeElement) => (el.value = ['2022-06-01', '2022-06-02', '2022-06-03']));
|
||||
await ionChange.next();
|
||||
await ionValueChange.next();
|
||||
|
||||
await expect(dateButton).toHaveText('3 days');
|
||||
});
|
||||
|
Reference in New Issue
Block a user