From 2c773ed0e6f82fb24c4940e78469caf60c908a07 Mon Sep 17 00:00:00 2001 From: Liam DeBeasi Date: Fri, 1 Dec 2023 15:29:40 -0500 Subject: [PATCH] fix: do not emit ionChange if value did not change --- .../picker-column/picker-column.tsx | 28 +++++++++---------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/core/src/components/picker-column/picker-column.tsx b/core/src/components/picker-column/picker-column.tsx index 0cfafe0224..7b6c491053 100644 --- a/core/src/components/picker-column/picker-column.tsx +++ b/core/src/components/picker-column/picker-column.tsx @@ -134,22 +134,18 @@ export class PickerColumn implements ComponentInterface { componentDidRender() { const { el, activeItem, isColumnVisible, value } = this; - if (isColumnVisible) { - if (activeItem) { - this.scrollActiveItemIntoView(); - } else { - const firstOption = el.querySelector('ion-picker-column-option'); + if (isColumnVisible && !activeItem) { + const firstOption = el.querySelector('ion-picker-column-option'); - /** - * If the picker column does not have an active item and the current value - * does not match the first item in the picker column, that means - * the value is out of bounds. In this case, we assign the value to the - * first item to match the scroll position of the column. - * - */ - if (firstOption !== null && firstOption.value !== value) { - this.setValue(firstOption.value); - } + /** + * If the picker column does not have an active item and the current value + * does not match the first item in the picker column, that means + * the value is out of bounds. In this case, we assign the value to the + * first item to match the scroll position of the column. + * + */ + if (firstOption !== null && firstOption.value !== value) { + this.setValue(firstOption.value); } } } @@ -173,6 +169,8 @@ export class PickerColumn implements ComponentInterface { */ @Method() async setValue(value?: string | number) { + if (this.value === value) { return; } + this.value = value; this.ionChange.emit(value); }