Skip to content

Commit

Permalink
fix: move to first match on search term change (#1416)
Browse files Browse the repository at this point in the history
* fix: update highlight/focus to first match on search term change

* pr comments
  • Loading branch information
adamstruck authored Apr 6, 2024
1 parent 357132a commit 3507385
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export const CodeMirrorSearchHighlighter: React.FC<{
}
);
}
}, [currentSearchResultIndex]);
}, [currentSearchItem]);

return null;
};
Original file line number Diff line number Diff line change
Expand Up @@ -142,16 +142,12 @@ export const SearchAndReplaceBar = React.forwardRef<
}));

const noPrevRes = React.useMemo(
() =>
searchResults.length === 0 ||
currentSearchResultIndex <= searchResults.length,
[searchResults.length, currentSearchResultIndex]
() => searchResults.length <= 1,
[searchResults.length]
);
const noNextRes = React.useMemo(
() =>
searchResults.length === 0 ||
currentSearchResultIndex >= searchResults.length,
[searchResults.length, currentSearchResultIndex]
() => searchResults.length <= 1,
[searchResults.length]
);

const searchRow = (
Expand Down

0 comments on commit 3507385

Please sign in to comment.