From 2f3f9dc9cab3b77bcc635101283932cf95b19807 Mon Sep 17 00:00:00 2001 From: Liam DeBeasi Date: Fri, 1 Dec 2023 14:58:01 -0500 Subject: [PATCH] refactor: clicking option sets value --- .../picker-column-option.tsx | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/core/src/components/picker-column-option/picker-column-option.tsx b/core/src/components/picker-column-option/picker-column-option.tsx index 56decf2763..8939ab6753 100644 --- a/core/src/components/picker-column-option/picker-column-option.tsx +++ b/core/src/components/picker-column-option/picker-column-option.tsx @@ -64,6 +64,19 @@ export class PickerColumnOption implements ComponentInterface { this.ariaLabel = inheritedAttributes['aria-label'] || null; } + /** + * When an option is clicked update the + * parent picker column value. This + * component will handle centering the option + * in the column view. + */ + onClick() { + const parentPickerColumn = this.el.closest('ion-picker-column'); + if (parentPickerColumn !== null) { + parentPickerColumn.setValue(this.value); + } + } + render() { const { color, value, disabled, ariaLabel } = this; const mode = getIonMode(this); @@ -75,7 +88,12 @@ export class PickerColumnOption implements ComponentInterface { ['option-disabled']: disabled, })} > -