From 1da54e53641d4a14a7ac29654ed2be4c55c65579 Mon Sep 17 00:00:00 2001 From: Eric Bailey Date: Wed, 10 Jan 2024 19:33:27 -0600 Subject: [PATCH] Clean up --- src/view/com/Dialog/index.web.tsx | 29 +++++++++++++++++++---------- src/view/com/Portal.tsx | 2 -- src/view/screens/DebugNew.tsx | 27 ++++++++++++++++++--------- 3 files changed, 37 insertions(+), 21 deletions(-) diff --git a/src/view/com/Dialog/index.web.tsx b/src/view/com/Dialog/index.web.tsx index b27c757029..f1576d6f33 100644 --- a/src/view/com/Dialog/index.web.tsx +++ b/src/view/com/Dialog/index.web.tsx @@ -4,13 +4,14 @@ import {FocusScope} from '@tamagui/focus-scope' import Animated, {FadeInDown, FadeIn, FadeOut} from 'react-native-reanimated' import {useTheme, atoms as a, useBreakpoints} from '#/alf' -import {EventStopper} from '#/view/com/util/EventStopper' import {Text} from '#/view/com/Typography' import {Portal} from '#/view/com/Portal' import {Button} from '#/view/com/Button' import {DialogProps, DialogControl} from '#/view/com/Dialog/types' +const stopPropagation = (e: any) => e.stopPropagation() + const Context = React.createContext<{ close: () => void }>({ @@ -58,6 +59,8 @@ export function Outer({ ) React.useEffect(() => { + if (!isOpen) return + function handler(e: KeyboardEvent) { if (e.key === 'Escape') close() } @@ -65,7 +68,7 @@ export function Outer({ document.addEventListener('keydown', handler) return () => document.removeEventListener('keydown', handler) - }, [close]) + }, [isOpen, close]) const context = React.useMemo(() => ({close}), [close]) @@ -105,14 +108,20 @@ export function Outer({ paddingTop: gtMobile ? ('10vh' as DimensionValue) : 0, }, ]}> - - - {children} - - + true} + onTouchEnd={stopPropagation}> + + + {children} + + + diff --git a/src/view/com/Portal.tsx b/src/view/com/Portal.tsx index 47a216bd80..1813d9e05e 100644 --- a/src/view/com/Portal.tsx +++ b/src/view/com/Portal.tsx @@ -33,8 +33,6 @@ export function Provider(props: React.PropsWithChildren<{}>) { setOutlet(<>{Object.values(map.current)}) }, []) - console.log(outlet) - return ( {props.children} diff --git a/src/view/screens/DebugNew.tsx b/src/view/screens/DebugNew.tsx index b6598cf669..24538bcb33 100644 --- a/src/view/screens/DebugNew.tsx +++ b/src/view/screens/DebugNew.tsx @@ -334,15 +334,24 @@ function Dialogs() { - - + + + +