diff --git a/packages/autocomplete-core/src/onKeyDown.ts b/packages/autocomplete-core/src/onKeyDown.ts index d45d7a566..bceda1491 100644 --- a/packages/autocomplete-core/src/onKeyDown.ts +++ b/packages/autocomplete-core/src/onKeyDown.ts @@ -34,7 +34,14 @@ export function onKeyDown({ const nodeItem = props.environment.document.getElementById( `${props.id}-item-${store.getState().highlightedIndex}` ); - nodeItem?.scrollIntoView(false); + + if (nodeItem) { + if ((nodeItem as any).scrollIntoViewIfNeeded) { + (nodeItem as any).scrollIntoViewIfNeeded(false); + } else { + nodeItem.scrollIntoView(false); + } + } const highlightedItem = getHighlightedItem({ state: store.getState(),