Skip to content

Commit

Permalink
Merge pull request #3 from ricosmall/patch-1
Browse files Browse the repository at this point in the history
Fix long list problem
  • Loading branch information
jackesdavid authored Oct 7, 2019
2 parents f642ee1 + f960909 commit f1b3d9b
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/hooks/useNavigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,13 @@ export const useNavigation = () => {
const selectThisElement = element === selectElement;
element.setAttribute("nav-selected", selectThisElement);
element.setAttribute("nav-index", index);
if (element.nodeName === 'INPUT') {
selectThisElement ? element.focus() : element.blur();
if (selectThisElement) {
selectThisElement.scrollIntoView(true);
if (element.nodeName === 'INPUT') {
element.focus();
} else {
element.blur();
}
}
});
setCurrent({ type: selectElement.tagName, index: setIndex });
Expand All @@ -58,4 +63,4 @@ export const useNavigation = () => {
}

return [current, setNavigation];
};
};

0 comments on commit f1b3d9b

Please sign in to comment.