Skip to content

Commit

Permalink
Merge pull request #4 from PDFTron/search-arrow-bug
Browse files Browse the repository at this point in the history
[bugfix] fixes #3
  • Loading branch information
mparizeau-pdftron authored Oct 12, 2018
2 parents c5ff3be + 5adc239 commit a284cf0
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/components/SearchOverlay/SearchOverlay.js
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,9 @@ class SearchOverlay extends React.PureComponent {
const { isSearchPanelOpen, activeResultIndex, results, setActiveResultIndex } = this.props;

if (isSearchPanelOpen) {
if (results.length === 0) {
return;
}
const nextResultIndex = activeResultIndex === results.length - 1 ? 0 : activeResultIndex + 1;
setActiveResultIndex(nextResultIndex);
core.setActiveSearchResult(results[nextResultIndex]);
Expand All @@ -262,6 +265,9 @@ class SearchOverlay extends React.PureComponent {
const { isSearchPanelOpen, activeResultIndex, results, setActiveResultIndex } = this.props;

if (isSearchPanelOpen) {
if (results.length === 0) {
return;
}
const prevResultIndex = activeResultIndex === 0 ? results.length - 1 : activeResultIndex - 1;
setActiveResultIndex(prevResultIndex);
core.setActiveSearchResult(results[prevResultIndex]);
Expand Down

0 comments on commit a284cf0

Please sign in to comment.