Skip to content

Commit

Permalink
feat(core): use scrollIntoViewIfNeeded if exists
Browse files Browse the repository at this point in the history
  • Loading branch information
francoischalifour committed Sep 25, 2020
1 parent 399be2b commit c409f11
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion packages/autocomplete-core/src/onKeyDown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,14 @@ export function onKeyDown<TItem>({
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(),
Expand Down

0 comments on commit c409f11

Please sign in to comment.