Skip to content

Commit

Permalink
fix: really check if node exist (#862)
Browse files Browse the repository at this point in the history
  • Loading branch information
barak007 authored Dec 20, 2023
1 parent 5657ec2 commit 28941d2
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,12 @@ export const useScrollListScrollToSelected = <T, EL extends HTMLElement>({

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,
Expand Down

0 comments on commit 28941d2

Please sign in to comment.