Skip to content

Commit

Permalink
adds handleSuggestWikiClose to clear search field and close container
Browse files Browse the repository at this point in the history
  • Loading branch information
Damola18 committed Jul 11, 2024
1 parent fcc7ded commit ebe3185
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/components/Layout/Navbar/NavSearch/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,12 @@ const NavSearch = (props: NavSearchProps) => {
onClose: onSuggestWikiClose,
} = useDisclosure()

// close Autocomplete container and clear query from the search field on modal close
const handleSuggestWikiClose = () => {
setQuery('')
onSuggestWikiClose()
}

useEventListener('keydown', (event) => {
const isMac = /(Mac|iPhone|iPod|iPad)/i.test(navigator?.userAgent)
const hotkey = isMac ? 'metaKey' : 'ctrlKey'
Expand Down Expand Up @@ -380,7 +386,7 @@ const NavSearch = (props: NavSearchProps) => {
</AutoComplete>
<SuggestWikiModal
isOpen={isSuggestWikiOpen}
onClose={onSuggestWikiClose}
onClose={handleSuggestWikiClose}
prePopulatedSearch={query}
/>
</>
Expand Down

0 comments on commit ebe3185

Please sign in to comment.