From 28941d2a8deee27e9df4be130d00c4786420f313 Mon Sep 17 00:00:00 2001 From: barak igal Date: Wed, 20 Dec 2023 13:03:48 +0200 Subject: [PATCH] fix: really check if node exist (#862) --- .../scroll-list/hooks/use-scroll-list-scroll-to-selected.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/components/src/scroll-list/hooks/use-scroll-list-scroll-to-selected.ts b/packages/components/src/scroll-list/hooks/use-scroll-list-scroll-to-selected.ts index 23349683..77d3f434 100644 --- a/packages/components/src/scroll-list/hooks/use-scroll-list-scroll-to-selected.ts +++ b/packages/components/src/scroll-list/hooks/use-scroll-list-scroll-to-selected.ts @@ -76,12 +76,12 @@ export const useScrollListScrollToSelected = ({ const scrollIntoView = (selected: number, position: ScrollLogicalPosition) => { const node = scrollListRef.current?.querySelector(`[data-id='${getId(items[selected]!)}']`); - if (node === null) { + if (!node) { timeout.current = window.setTimeout( () => isScrollingToSelection.current && scrollTo(selected, true) ); } else { - scrollIntoViewIfNeeded(node!, { + scrollIntoViewIfNeeded(node, { scrollMode: 'if-needed', block: position, inline: position,