11import { useMemo } from 'react' ;
2- import type { FC } from 'react' ;
32
43import { createPortal } from 'react-dom' ;
54import { StyleSheet , View , Pressable } from 'react-native' ;
65
76import { useID } from './hooks/useID' ;
87import { useModalRegistry } from './hooks/useModalRegistry' ;
8+
9+ import type { MouseEvent } from 'react' ;
910import type { ModalViewProps } from './types' ;
1011
1112export type ModalViewWebProps = Omit <
@@ -24,7 +25,7 @@ export enum DismissalSource {
2425 Backdrop = 'Backdrop' ,
2526}
2627
27- export const ModalView : FC < ModalViewWebProps > = ( {
28+ export const ModalView = ( {
2829 modalId,
2930 children,
3031 renderBackdrop,
@@ -33,7 +34,7 @@ export const ModalView: FC<ModalViewWebProps> = ({
3334 BackdropPressableComponent = Pressable ,
3435 backdropColor = defaultBackdropColor ,
3536 animationType = 'none' ,
36- } ) => {
37+ } : ModalViewWebProps ) => {
3738 const currentModalId = useID ( modalId ) ;
3839 const { modals, isBackdropVisible } = useModalRegistry ( currentModalId ) ;
3940 const modalIsOpen = modals . has ( currentModalId ) ;
@@ -65,7 +66,13 @@ export const ModalView: FC<ModalViewWebProps> = ({
6566 styles . backdropPressable ,
6667 ! isBackdropVisible && styles . backdropHidden ,
6768 ] }
68- onPress = { ( ) => onRequestDismiss ?.( DismissalSource . Backdrop ) }
69+ onPress = { ( e ) => {
70+ const event = e as unknown as MouseEvent < HTMLElement > ;
71+
72+ if ( event . target === event . currentTarget ) {
73+ onRequestDismiss ?.( DismissalSource . Backdrop ) ;
74+ }
75+ } }
6976 >
7077 { renderBackdrop ? (
7178 renderBackdrop ( )
0 commit comments