mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-11-10 00:27:41 +08:00
fix(datetime): presentation time emits ionChange once (#24968)
Resolves #24967
This commit is contained in:
@ -67,16 +67,10 @@ export class PickerColumnInternal implements ComponentInterface {
|
||||
valueChange() {
|
||||
if (this.isColumnVisible) {
|
||||
/**
|
||||
* Only scroll the active item into view and emit the value
|
||||
* change, when the picker column is actively visible to the user.
|
||||
* Only scroll the active item into view when the picker column
|
||||
* is actively visible to the user.
|
||||
*/
|
||||
const { items, value } = this;
|
||||
this.scrollActiveItemIntoView();
|
||||
|
||||
const findItem = items.find(item => item.value === value);
|
||||
if (findItem) {
|
||||
this.ionChange.emit(findItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -133,7 +127,7 @@ export class PickerColumnInternal implements ComponentInterface {
|
||||
* first item to match the scroll position of the column.
|
||||
*
|
||||
*/
|
||||
this.value = items[0].value;
|
||||
this.setValue(items[0].value);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -148,6 +142,15 @@ export class PickerColumnInternal implements ComponentInterface {
|
||||
}
|
||||
}
|
||||
|
||||
private setValue(value?: string | number) {
|
||||
const { items } = this;
|
||||
this.value = value;
|
||||
const findItem = items.find(item => item.value === value);
|
||||
if (findItem) {
|
||||
this.ionChange.emit(findItem);
|
||||
}
|
||||
}
|
||||
|
||||
private centerPickerItemInView = (target: HTMLElement, smooth = true) => {
|
||||
const { el, isColumnVisible } = this;
|
||||
if (isColumnVisible) {
|
||||
@ -250,7 +253,7 @@ export class PickerColumnInternal implements ComponentInterface {
|
||||
const selectedItem = this.items[index];
|
||||
|
||||
if (selectedItem.value !== this.value) {
|
||||
this.value = selectedItem.value;
|
||||
this.setValue(selectedItem.value);
|
||||
hapticSelectionEnd();
|
||||
this.hapticsStarted = false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user