diff options
| author | Armand Philippot <git@armandphilippot.com> | 2022-05-18 14:27:11 +0200 |
|---|---|---|
| committer | Armand Philippot <git@armandphilippot.com> | 2022-05-18 14:27:11 +0200 |
| commit | b214baab3e17d92f784b4f782863deafc5558ee4 (patch) | |
| tree | cdc20c7e77ba6926285917eead8bb088bdc843f8 /src/components/organisms/toolbar/search.tsx | |
| parent | 54883bb5c36cf21462a421605a709fdd6f04b150 (diff) | |
chore: close toolbar modals on click/focus outside
Diffstat (limited to 'src/components/organisms/toolbar/search.tsx')
| -rw-r--r-- | src/components/organisms/toolbar/search.tsx | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/src/components/organisms/toolbar/search.tsx b/src/components/organisms/toolbar/search.tsx index a1471ef..5695348 100644 --- a/src/components/organisms/toolbar/search.tsx +++ b/src/components/organisms/toolbar/search.tsx @@ -1,7 +1,7 @@ import Checkbox, { type CheckboxProps } from '@components/atoms/forms/checkbox'; import Label from '@components/atoms/forms/label'; import MagnifyingGlass from '@components/atoms/icons/magnifying-glass'; -import { FC } from 'react'; +import { forwardRef, ForwardRefRenderFunction } from 'react'; import { useIntl } from 'react-intl'; import SearchModal, { type SearchModalProps } from '../modals/search-modal'; import searchStyles from './search.module.scss'; @@ -26,12 +26,10 @@ export type SearchProps = { setIsActive: CheckboxProps['setValue']; }; -const Search: FC<SearchProps> = ({ - className = '', - isActive, - searchPage, - setIsActive, -}) => { +const Search: ForwardRefRenderFunction<HTMLDivElement, SearchProps> = ( + { className = '', isActive, searchPage, setIsActive }, + ref +) => { const intl = useIntl(); const label = isActive ? intl.formatMessage({ @@ -46,7 +44,7 @@ const Search: FC<SearchProps> = ({ }); return ( - <div className={`${sharedStyles.item} ${searchStyles.item}`}> + <div className={`${sharedStyles.item} ${searchStyles.item}`} ref={ref}> <Checkbox id="search-button" name="search-button" @@ -69,4 +67,4 @@ const Search: FC<SearchProps> = ({ ); }; -export default Search; +export default forwardRef(Search); |
