aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/organisms/toolbar/settings.tsx
diff options
context:
space:
mode:
authorArmand Philippot <git@armandphilippot.com>2022-05-18 14:27:11 +0200
committerArmand Philippot <git@armandphilippot.com>2022-05-18 14:27:11 +0200
commitb214baab3e17d92f784b4f782863deafc5558ee4 (patch)
treecdc20c7e77ba6926285917eead8bb088bdc843f8 /src/components/organisms/toolbar/settings.tsx
parent54883bb5c36cf21462a421605a709fdd6f04b150 (diff)
chore: close toolbar modals on click/focus outside
Diffstat (limited to 'src/components/organisms/toolbar/settings.tsx')
-rw-r--r--src/components/organisms/toolbar/settings.tsx16
1 files changed, 7 insertions, 9 deletions
diff --git a/src/components/organisms/toolbar/settings.tsx b/src/components/organisms/toolbar/settings.tsx
index 3b10226..43d3190 100644
--- a/src/components/organisms/toolbar/settings.tsx
+++ b/src/components/organisms/toolbar/settings.tsx
@@ -1,7 +1,7 @@
import Checkbox, { type CheckboxProps } from '@components/atoms/forms/checkbox';
import Label from '@components/atoms/forms/label';
import Cog from '@components/atoms/icons/cog';
-import { FC } from 'react';
+import { FC, forwardRef, ForwardRefRenderFunction } from 'react';
import { useIntl } from 'react-intl';
import SettingsModal, {
type SettingsModalProps,
@@ -28,12 +28,10 @@ export type SettingsProps = {
tooltipClassName?: SettingsModalProps['tooltipClassName'];
};
-const Settings: FC<SettingsProps> = ({
- className = '',
- isActive,
- setIsActive,
- tooltipClassName = '',
-}) => {
+const Settings: ForwardRefRenderFunction<HTMLDivElement, SettingsProps> = (
+ { className = '', isActive, setIsActive, tooltipClassName = '' },
+ ref
+) => {
const intl = useIntl();
const label = isActive
? intl.formatMessage({
@@ -48,7 +46,7 @@ const Settings: FC<SettingsProps> = ({
});
return (
- <div className={`${sharedStyles.item} ${settingsStyles.item}`}>
+ <div className={`${sharedStyles.item} ${settingsStyles.item}`} ref={ref}>
<Checkbox
id="settings-button"
name="settings-button"
@@ -71,4 +69,4 @@ const Settings: FC<SettingsProps> = ({
);
};
-export default Settings;
+export default forwardRef(Settings);