File tree Expand file tree Collapse file tree 1 file changed +4
-1
lines changed
Expand file tree Collapse file tree 1 file changed +4
-1
lines changed Original file line number Diff line number Diff line change @@ -95,10 +95,13 @@ function useClickOutside(
9595 if ( disabled || ref == null ) return undefined ;
9696
9797 const doc = ownerDocument ( getRefTarget ( ref ) ! ) ;
98+ const ownerWindow = doc . defaultView || window ;
9899
99100 // Store the current event to avoid triggering handlers immediately
101+ // For things rendered in an iframe, the event might originate on the parent window
102+ // so we should fall back to that global event if the local one doesn't exist
100103 // https://github.com/facebook/react/issues/20074
101- let currentEvent = ( doc . defaultView || window ) . event ;
104+ let currentEvent = ownerWindow . event ?? ownerWindow . parent ? .event ;
102105
103106 let removeInitialTriggerListener : ( ( ) => void ) | null = null ;
104107 if ( InitialTriggerEvents [ clickTrigger ] ) {
You can’t perform that action at this time.
0 commit comments