diff options
author | Minseo Lee <itoupluk427@gmail.com> | 2024-02-29 13:05:45 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-29 13:05:45 +0900 |
commit | 200c4c1d379e591e82d6d1bd065a443f6abc03f5 (patch) | |
tree | db7257f0178b2d9514642a7faf3e003d60d2b418 /src/components/Dialog/index.tsx | |
parent | a1127bfcfc7ad080a5bd6210c6561788f1643db8 (diff) | |
parent | a35976cdc9b6467ad8b6e0c4ff46ba684fee9064 (diff) | |
download | voidsky-200c4c1d379e591e82d6d1bd065a443f6abc03f5.tar.zst |
Merge branch 'bluesky-social:main' into patch-3
Diffstat (limited to 'src/components/Dialog/index.tsx')
-rw-r--r-- | src/components/Dialog/index.tsx | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/components/Dialog/index.tsx b/src/components/Dialog/index.tsx index 5c0350274..6dfc24f3b 100644 --- a/src/components/Dialog/index.tsx +++ b/src/components/Dialog/index.tsx @@ -12,6 +12,7 @@ import {useTheme, atoms as a, flatten} from '#/alf' import {Portal} from '#/components/Portal' import {createInput} from '#/components/forms/TextField' import {logger} from '#/logger' +import {useDialogStateContext} from '#/state/dialogs' import { DialogOuterProps, @@ -37,6 +38,7 @@ export function Outer({ const hasSnapPoints = !!sheetOptions.snapPoints const insets = useSafeAreaInsets() const closeCallback = React.useRef<() => void>() + const {openDialogs} = useDialogStateContext() /* * Used to manage open/closed, but index is otherwise handled internally by `BottomSheet` @@ -50,10 +52,11 @@ export function Outer({ const open = React.useCallback<DialogControlProps['open']>( ({index} = {}) => { + openDialogs.current.add(control.id) // can be set to any index of `snapPoints`, but `0` is the first i.e. "open" setOpenIndex(index || 0) }, - [setOpenIndex], + [setOpenIndex, openDialogs, control.id], ) const close = React.useCallback<DialogControlProps['close']>(cb => { @@ -85,11 +88,12 @@ export function Outer({ closeCallback.current = undefined } + openDialogs.current.delete(control.id) onClose?.() setOpenIndex(-1) } }, - [onClose, setOpenIndex], + [onClose, setOpenIndex, openDialogs, control.id], ) const context = React.useMemo(() => ({close}), [close]) |