fix(mobile): disable navigation gesture for swipe-dialog (#8993)

This commit is contained in:
CatsJuice
2024-12-12 06:55:15 +00:00
parent 01b6e43c1f
commit 84df2a1d16
6 changed files with 71 additions and 50 deletions

View File

@@ -1,10 +1,12 @@
import { createContext } from 'react';
type OnClose = (() => void) | undefined;
export interface ModalConfig {
/**
* add global callback for modal open/close
* add global callback for modal open,
* return a function to handle close/unmount callback
*/
onOpenChange?: (open: boolean) => void;
onOpen?: () => OnClose;
}
export const ModalConfigContext = createContext<ModalConfig>({});

View File

@@ -130,7 +130,7 @@ function createContainer() {
export const ModalInner = forwardRef<HTMLDivElement, ModalProps>(
(props, ref) => {
const modalConfig = useContext(ModalConfigContext);
const { onOpen: modalConfigOnOpen } = useContext(ModalConfigContext);
const {
modal,
portalOptions,
@@ -173,8 +173,9 @@ export const ModalInner = forwardRef<HTMLDivElement, ModalProps>(
);
useEffect(() => {
modalConfig.onOpenChange?.(open ?? false);
}, [modalConfig, open]);
if (open) return modalConfigOnOpen?.();
return;
}, [modalConfigOnOpen, open]);
useEffect(() => {
if (open) {