mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-13 12:55:00 +00:00
fix(mobile): disable navigation gesture for swipe-dialog (#8993)
This commit is contained in:
@@ -6,22 +6,19 @@ import { type PropsWithChildren, useCallback } from 'react';
|
||||
export const ModalConfigProvider = ({ children }: PropsWithChildren) => {
|
||||
const navigationGesture = useService(NavigationGestureService);
|
||||
|
||||
const onOpenChange = useCallback(
|
||||
(open: boolean) => {
|
||||
const prev = navigationGesture.enabled$.value;
|
||||
if (open && !prev) {
|
||||
navigationGesture.setEnabled(false);
|
||||
return () => {
|
||||
navigationGesture.setEnabled(prev);
|
||||
};
|
||||
}
|
||||
return;
|
||||
},
|
||||
[navigationGesture]
|
||||
);
|
||||
const onOpen = useCallback(() => {
|
||||
const prev = navigationGesture.enabled$.value;
|
||||
if (prev) {
|
||||
navigationGesture.setEnabled(false);
|
||||
return () => {
|
||||
navigationGesture.setEnabled(prev);
|
||||
};
|
||||
}
|
||||
return;
|
||||
}, [navigationGesture]);
|
||||
|
||||
return (
|
||||
<ModalConfigContext.Provider value={{ onOpenChange }}>
|
||||
<ModalConfigContext.Provider value={{ onOpen }}>
|
||||
{children}
|
||||
</ModalConfigContext.Provider>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user