Skip to content

Commit

Permalink
Correct crash with specific navigation case
Browse files Browse the repository at this point in the history
  • Loading branch information
Zefling committed Oct 16, 2017
1 parent 93615cb commit e882cf5
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -248,12 +248,18 @@ export function getLastScrollTopIndex(
const scrollTop = getScrollUpIndex(filteredData, hoveringValue);
if (scrollTop - lastScrollTopIndex > 5) {
lastScrollTopIndex += scrollTop - lastScrollTopIndex - 5;
results.scrollTop = results.querySelectorAll("li").item(scrollTop).offsetTop - results.offsetHeight;
const item = results.querySelectorAll("li").item(scrollTop);
if (item) {
results.scrollTop = item.offsetTop - results.offsetHeight;
}
return lastScrollTopIndex;
}
if (lastScrollTopIndex - scrollTop > 0) {
lastScrollTopIndex -= lastScrollTopIndex - scrollTop;
results.scrollTop = results.querySelectorAll("li").item(lastScrollTopIndex - 1).offsetTop;
const item = results.querySelectorAll("li").item(lastScrollTopIndex - 1);
if (item) {
results.scrollTop = item.offsetTop;
}
return lastScrollTopIndex;
}
return null;
Expand Down

0 comments on commit e882cf5

Please sign in to comment.