mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-12 12:28:42 +00:00
fix(mobile): disable navigation gesture for swipe-dialog (#8993)
This commit is contained in:
@@ -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>({});
|
||||
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user