Skip to content

Commit

Permalink
🐛 Re-render cmd palette results when typeaheadResults are fetched (#147)
Browse files Browse the repository at this point in the history
* 🐛 Re-render cmd palette results when typeaheadResults are fetched

* 🐛 Avoid making requests if the query is empty
  • Loading branch information
foysalit authored Jul 5, 2024
1 parent 5137cf9 commit 134524d
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions components/shell/CommandPalette/useAsyncSearch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,10 @@ export const useCommandPaletteAsyncSearch = () => {
search: state.searchQuery,
}))

const { data: typeaheadResults } = useSearchActorsTypeahead(search)
// Only pass the query to the typeahead if it starts with @ since we want to show other results for input that does not start with @
const { data: typeaheadResults } = useSearchActorsTypeahead(
search.startsWith('@') ? search : '',
)

const [didFromHandle, setDidFromHandle] = useState<{
did: string
Expand Down Expand Up @@ -427,5 +430,5 @@ export const useCommandPaletteAsyncSearch = () => {
return actions.map(createAction)
}, [search, didFromHandle, typeaheadResults])

useRegisterActions(memoizedActions, [search, didFromHandle])
useRegisterActions(memoizedActions, [search, didFromHandle, typeaheadResults])
}

0 comments on commit 134524d

Please sign in to comment.