@@ -25,7 +25,7 @@ interface ModalContextType {
2525 trapFocus : boolean ;
2626}
2727
28- const [ ModalProvider , useModalContext ] = createContext < ModalContextType > ( ) ;
28+ const [ ModalProvider , useModalContext ] = createContext < ModalContextType > ( "Modal" ) ;
2929
3030const getState = ( open : boolean ) => {
3131 return open ? "open" : "closed" ;
@@ -80,7 +80,7 @@ interface ModalTriggerProps extends React.ComponentPropsWithoutRef<"button"> {
8080
8181const ModalTrigger = React . forwardRef < HTMLButtonElement , ModalTriggerProps > ( ( props , forwardedRef ) => {
8282 const { asChild, ...triggerProps } = props ;
83- const context = useModalContext ( ) ;
83+ const context = useModalContext ( "ModalTrigger" ) ;
8484 const triggerRef = useComposedRef ( forwardedRef , context . triggerRef ) ;
8585 const Component = asChild ? Slot : "button" ;
8686
@@ -104,7 +104,7 @@ interface ModalContentProps extends React.ComponentPropsWithoutRef<"div"> {}
104104
105105const ModalContentInner = React . forwardRef < HTMLDivElement , ModalContentProps > ( ( props , forwardedRef ) => {
106106 const { autoFocus = true , ...contentProps } = props ;
107- const context = useModalContext ( ) ;
107+ const context = useModalContext ( "ModalContentInner" ) ;
108108
109109 const [ focusContainer , setFocusContainer ] = React . useState < HTMLElement | null > ( ) ;
110110 const previousFocus = React . useRef < HTMLElement | null > ( null ) ;
@@ -155,7 +155,7 @@ const ModalContentInner = React.forwardRef<HTMLDivElement, ModalContentProps>((p
155155ModalContentInner . displayName = "ModalContentInner" ;
156156
157157const ModalContent = React . forwardRef < HTMLDivElement , ModalContentProps > ( ( { ...contentProps } , forwardedRef ) => {
158- const context = useModalContext ( ) ;
158+ const context = useModalContext ( "ModalContent" ) ;
159159
160160 return context . modal ? (
161161 < ModalPortal >
@@ -173,7 +173,7 @@ ModalContent.displayName = "ModalContent";
173173interface ModalPortalProps extends React . ComponentPropsWithoutRef < "div" > { }
174174
175175const ModalPortal = ( { children, ...portalProps } : ModalPortalProps ) => {
176- const context = useModalContext ( ) ;
176+ const context = useModalContext ( "ModalPortal" ) ;
177177
178178 return React . Children . map ( children , ( child ) => (
179179 < Presence present = { context . open } >
@@ -187,7 +187,7 @@ ModalPortal.displayName = "ModalPortal";
187187interface ModalOverlayInnerProps extends React . ComponentPropsWithoutRef < "div" > { }
188188
189189const ModalOverlayInner = React . forwardRef < HTMLDivElement , ModalOverlayInnerProps > ( ( { ...overlayProps } , forwardedRef ) => {
190- const context = useModalContext ( ) ;
190+ const context = useModalContext ( "ModalOverlayInner" ) ;
191191
192192 return (
193193 < RemoveScroll as = { Slot } allowPinchZoom shards = { [ context . contentRef ] } >
@@ -208,7 +208,7 @@ ModalOverlayInner.displayName = "ModalOverlayInner";
208208interface ModalOverlayProps extends React . ComponentPropsWithoutRef < "div" > { }
209209
210210const ModalOverlay = React . forwardRef < HTMLDivElement , ModalOverlayProps > ( ( { ...overlayProps } , forwardedRef ) => {
211- const context = useModalContext ( ) ;
211+ const context = useModalContext ( "ModalOverlay" ) ;
212212 return context . modal ? (
213213 < Presence present = { context . open } >
214214 < ModalOverlayInner { ...overlayProps } ref = { forwardedRef } />
0 commit comments