chore(web): Disable page scroll when using arrow keys on search suggestions box (#493)

This commit is contained in:
Brendan Kellam 2025-09-06 12:16:57 -04:00 committed by GitHub
parent a74d070775
commit 2309b67999
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 5 additions and 0 deletions

View file

@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased] ## [Unreleased]
### Changed
- Disable page scroll when using arrow keys on search suggestions box. [#493](https://github.com/sourcebot-dev/sourcebot/pull/493)
## [4.6.6] - 2025-09-04 ## [4.6.6] - 2025-09-04
### Added ### Added

View file

@ -334,6 +334,7 @@ const SearchSuggestionsBox = forwardRef(({
} }
if (e.key === 'ArrowUp') { if (e.key === 'ArrowUp') {
e.preventDefault();
e.stopPropagation(); e.stopPropagation();
setHighlightedSuggestionIndex((curIndex) => { setHighlightedSuggestionIndex((curIndex) => {
return curIndex <= 0 ? suggestions.length - 1 : curIndex - 1; return curIndex <= 0 ? suggestions.length - 1 : curIndex - 1;
@ -341,6 +342,7 @@ const SearchSuggestionsBox = forwardRef(({
} }
if (e.key === 'ArrowDown') { if (e.key === 'ArrowDown') {
e.preventDefault();
e.stopPropagation(); e.stopPropagation();
setHighlightedSuggestionIndex((curIndex) => { setHighlightedSuggestionIndex((curIndex) => {
return curIndex >= suggestions.length - 1 ? 0 : curIndex + 1; return curIndex >= suggestions.length - 1 ? 0 : curIndex + 1;