diff --git a/src/primitives/Column.tsx b/src/primitives/Column.tsx index 2782fb4d..082386ae 100644 --- a/src/primitives/Column.tsx +++ b/src/primitives/Column.tsx @@ -21,8 +21,9 @@ function scrollToIndex( index: number, options?: { noFocus?: boolean }, ): void { + const lastSelected = this.selected; this.selected = index; - scrollColumn(index, this); + scrollColumn(index, this, undefined, lastSelected === index ? undefined : lastSelected); if (!options?.noFocus) { this.children[index]?.setFocus(); } diff --git a/src/primitives/Row.tsx b/src/primitives/Row.tsx index d397e467..d2d13dfe 100644 --- a/src/primitives/Row.tsx +++ b/src/primitives/Row.tsx @@ -19,9 +19,10 @@ const RowStyles: NodeStyles = { gap: 30, }; -function scrollToIndex(this: ElementNode, index: number, options?: {noFocus?: boolean}) { +function scrollToIndex(this: ElementNode, index: number, options?: { noFocus?: boolean }) { + const lastSelected = this.selected; this.selected = index; - scrollRow(index, this); + scrollRow(index, this, undefined, lastSelected === index ? undefined : lastSelected); if (!options?.noFocus) { this.children[index]?.setFocus(); }