Skip to content

Commit

Permalink
fix: always highlight first item in home view
Browse files Browse the repository at this point in the history
  • Loading branch information
d-rita committed Jan 25, 2025
1 parent 1970312 commit 11d2fad
Showing 1 changed file with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,20 @@ export const useNavigation = ({
setActiveSection,
} = useCommandPaletteContext()

const defaultSection = showGrid ? 'grid' : 'actions'

// highlight first item in filtered results
useEffect(() => {
setHighlightedIndex(0)
}, [filter, setHighlightedIndex])

const defaultSection = showGrid ? 'grid' : 'actions'
// highlight first item in home view
useEffect(() => {
if (currentView === 'home' && !activeSection) {
setActiveSection(defaultSection)
setHighlightedIndex(0)
}
}, [])

Check warning on line 40 in components/header-bar/src/command-palette/hooks/use-navigation.js

View workflow job for this annotation

GitHub Actions / lint

React Hook useEffect has missing dependencies: 'activeSection', 'currentView', 'defaultSection', 'setActiveSection', and 'setHighlightedIndex'. Either include them or remove the dependency array

Check warning on line 40 in components/header-bar/src/command-palette/hooks/use-navigation.js

View workflow job for this annotation

GitHub Actions / lint

React Hook useEffect has missing dependencies: 'activeSection', 'currentView', 'defaultSection', 'setActiveSection', and 'setHighlightedIndex'. Either include them or remove the dependency array

const goToDefaultView = useCallback(() => {
setFilter('')
Expand Down Expand Up @@ -256,7 +264,5 @@ export const useNavigation = ({
handleKeyDown,
goToDefaultView,
modalRef,
activeSection,
setActiveSection,
}
}

0 comments on commit 11d2fad

Please sign in to comment.