diff options
| author | Armand Philippot <git@armandphilippot.com> | 2022-06-08 12:07:08 +0200 |
|---|---|---|
| committer | Armand Philippot <git@armandphilippot.com> | 2022-06-08 12:19:28 +0200 |
| commit | 58cb40f031f395ca9efccff674ba0f2dae723f50 (patch) | |
| tree | d69539a66a83da85689b8f7e835492eedc068e1f /src/components/organisms | |
| parent | 43bddd9506d790ad6707fe71f28a4ecfa635c8f1 (diff) | |
fix(settings): close tooltip when modal is closing
The event was not captured so the tooltip remained open when the
settings was closed. It prevented to click on the toolbar buttons.
Diffstat (limited to 'src/components/organisms')
| -rw-r--r-- | src/components/organisms/modals/settings-modal.module.scss | 1 | ||||
| -rw-r--r-- | src/components/organisms/modals/settings-modal.tsx | 1 | ||||
| -rw-r--r-- | src/components/organisms/toolbar/toolbar.tsx | 21 |
3 files changed, 11 insertions, 12 deletions
diff --git a/src/components/organisms/modals/settings-modal.module.scss b/src/components/organisms/modals/settings-modal.module.scss deleted file mode 100644 index 70b786d..0000000 --- a/src/components/organisms/modals/settings-modal.module.scss +++ /dev/null @@ -1 +0,0 @@ -// TODO diff --git a/src/components/organisms/modals/settings-modal.tsx b/src/components/organisms/modals/settings-modal.tsx index 34f5619..0ab6b7a 100644 --- a/src/components/organisms/modals/settings-modal.tsx +++ b/src/components/organisms/modals/settings-modal.tsx @@ -4,7 +4,6 @@ import dynamic from 'next/dynamic'; import { FC } from 'react'; import { useIntl } from 'react-intl'; import { type SettingsFormProps } from '../forms/settings-form'; -import styles from './settings-modal.module.scss'; const DynamicSettingsForm = dynamic( () => import('@components/organisms/forms/settings-form'), diff --git a/src/components/organisms/toolbar/toolbar.tsx b/src/components/organisms/toolbar/toolbar.tsx index c18b8ea..50fc7f2 100644 --- a/src/components/organisms/toolbar/toolbar.tsx +++ b/src/components/organisms/toolbar/toolbar.tsx @@ -1,9 +1,9 @@ -import useClickOutside from '@utils/hooks/use-click-outside'; +import useOnClickOutside from '@utils/hooks/use-on-click-outside'; import useRouteChange from '@utils/hooks/use-route-change'; -import { FC, useRef, useState } from 'react'; +import { FC, useState } from 'react'; import MainNav, { type MainNavProps } from '../toolbar/main-nav'; import Search, { type SearchProps } from '../toolbar/search'; -import Settings, { SettingsProps } from '../toolbar/settings'; +import Settings, { type SettingsProps } from '../toolbar/settings'; import styles from './toolbar.module.scss'; export type ToolbarProps = Pick<SearchProps, 'searchPage'> & @@ -33,16 +33,17 @@ const Toolbar: FC<ToolbarProps> = ({ const [isNavOpened, setIsNavOpened] = useState<boolean>(false); const [isSearchOpened, setIsSearchOpened] = useState<boolean>(false); const [isSettingsOpened, setIsSettingsOpened] = useState<boolean>(false); - const mainNavRef = useRef<HTMLDivElement>(null); - const searchRef = useRef<HTMLDivElement>(null); - const settingsRef = useRef<HTMLDivElement>(null); - useClickOutside(mainNavRef, () => isNavOpened && setIsNavOpened(false)); - useClickOutside(searchRef, () => isSearchOpened && setIsSearchOpened(false)); - useClickOutside( - settingsRef, + const mainNavRef = useOnClickOutside<HTMLDivElement>( + () => isNavOpened && setIsNavOpened(false) + ); + const searchRef = useOnClickOutside<HTMLDivElement>( + () => isSearchOpened && setIsSearchOpened(false) + ); + const settingsRef = useOnClickOutside<HTMLDivElement>( () => isSettingsOpened && setIsSettingsOpened(false) ); + useRouteChange(() => setIsSearchOpened(false)); return ( |
