diff options
author | Jan-Olof Eriksson <jan-olof.eriksson@iki.fi> | 2024-02-29 11:55:03 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-29 11:55:03 +0200 |
commit | 963a44ab872a1044d6997a8fcf7b2fc754ac618a (patch) | |
tree | bbd64f464a8f14e55cbb06e28811cdc43f059d29 /src/components/Dialog/index.web.tsx | |
parent | 1f9562847512bb41cd8bb381b735a388be4db59b (diff) | |
parent | a35976cdc9b6467ad8b6e0c4ff46ba684fee9064 (diff) | |
download | voidsky-963a44ab872a1044d6997a8fcf7b2fc754ac618a.tar.zst |
Merge branch 'bluesky-social:main' into main
Diffstat (limited to 'src/components/Dialog/index.web.tsx')
-rw-r--r-- | src/components/Dialog/index.web.tsx | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/components/Dialog/index.web.tsx b/src/components/Dialog/index.web.tsx index 79441fb5e..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, @@ -188,9 +192,9 @@ export function Close() { <Button size="small" variant="ghost" - color="primary" + color="secondary" shape="round" - onPress={close} + onPress={() => close()} label={_(msg`Close active dialog`)}> <ButtonIcon icon={X} size="md" /> </Button> |