Commit 35a429ea authored by Charles Bachmeier's avatar Charles Bachmeier Committed by GitHub

feat: highlight first result by default (#4551)

highlight first result by default
Co-authored-by: default avatarCharlie <charlie@uniswap.org>
parent bd16543c
...@@ -90,7 +90,7 @@ interface SearchBarDropdownProps { ...@@ -90,7 +90,7 @@ interface SearchBarDropdownProps {
} }
export const SearchBarDropdown = ({ toggleOpen, tokens, collections, hasInput }: SearchBarDropdownProps) => { export const SearchBarDropdown = ({ toggleOpen, tokens, collections, hasInput }: SearchBarDropdownProps) => {
const [hoveredIndex, setHoveredIndex] = useState<number | undefined>(undefined) const [hoveredIndex, setHoveredIndex] = useState<number | undefined>(0)
const searchHistory = useSearchHistory( const searchHistory = useSearchHistory(
(state: { history: (FungibleToken | GenieCollection)[] }) => state.history (state: { history: (FungibleToken | GenieCollection)[] }) => state.history
).slice(0, 2) ).slice(0, 2)
...@@ -185,6 +185,7 @@ export const SearchBarDropdown = ({ toggleOpen, tokens, collections, hasInput }: ...@@ -185,6 +185,7 @@ export const SearchBarDropdown = ({ toggleOpen, tokens, collections, hasInput }:
setHoveredIndex(hoveredIndex - 1) setHoveredIndex(hoveredIndex - 1)
} }
} else if (event.key === 'ArrowDown') { } else if (event.key === 'ArrowDown') {
event.preventDefault()
if (hoveredIndex && hoveredIndex === totalSuggestions - 1) { if (hoveredIndex && hoveredIndex === totalSuggestions - 1) {
setHoveredIndex(0) setHoveredIndex(0)
} else { } else {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment