diff options
author | Eric Bailey <git@esb.lol> | 2024-02-28 20:06:26 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-28 20:06:26 -0600 |
commit | 2440975bd224e4c39b633b21c461cb8b8d3c1f9b (patch) | |
tree | 8acfba6fec870808c36853d6005a53ed12542456 /src/components/Dialog/index.web.tsx | |
parent | 7fd13cacfea4e9e4609ac2cfa11749544fc2f8f8 (diff) | |
download | voidsky-2440975bd224e4c39b633b21c461cb8b8d3c1f9b.tar.zst |
Integrate new dialogs into old back handling (#3023)
Diffstat (limited to 'src/components/Dialog/index.web.tsx')
-rw-r--r-- | src/components/Dialog/index.web.tsx | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/components/Dialog/index.web.tsx b/src/components/Dialog/index.web.tsx index ff05fed91..32163e735 100644 --- a/src/components/Dialog/index.web.tsx +++ b/src/components/Dialog/index.web.tsx @@ -12,6 +12,7 @@ import {DialogOuterProps, DialogInnerProps} from '#/components/Dialog/types' import {Context} from '#/components/Dialog/context' import {Button, ButtonIcon} from '#/components/Button' import {TimesLarge_Stroke2_Corner0_Rounded as X} from '#/components/icons/Times' +import {useDialogStateContext} from '#/state/dialogs' export {useDialogControl, useDialogContext} from '#/components/Dialog/context' export * from '#/components/Dialog/types' @@ -29,18 +30,21 @@ export function Outer({ const {gtMobile} = useBreakpoints() const [isOpen, setIsOpen] = React.useState(false) const [isVisible, setIsVisible] = React.useState(true) + const {openDialogs} = useDialogStateContext() const open = React.useCallback(() => { setIsOpen(true) - }, [setIsOpen]) + openDialogs.current.add(control.id) + }, [setIsOpen, openDialogs, control.id]) const close = React.useCallback(async () => { setIsVisible(false) await new Promise(resolve => setTimeout(resolve, 150)) setIsOpen(false) setIsVisible(true) + openDialogs.current.delete(control.id) onClose?.() - }, [onClose, setIsOpen]) + }, [onClose, setIsOpen, openDialogs, control.id]) useImperativeHandle( control.ref, |