From d99b4884c997209bb4b570e3e1850ba7d0a08fd0 Mon Sep 17 00:00:00 2001 From: Lucca Lazzarini Date: Fri, 10 Jul 2026 09:40:20 -0300 Subject: [PATCH] Patch scrollToIndex to scroll backwards --- src/primitives/Column.tsx | 3 ++- src/primitives/Row.tsx | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) 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(); }