Skip to content

Failed to read a named property 'event' from 'Window' #123

@zdila

Description

@zdila

Describe the bug

My app crashes with JS error:

Failed to read a named property 'event' from 'Window': Blocked a frame with origin "http://localhost:8080" from accessing a cross-origin frame.

To Reproduce

Steps to reproduce the behavior:

  1. Use react-bootstrap with <DroprownMenu> component
  2. Use the app in iframe
  3. Open dropdown menu

Expected behavior

No exception.

Environment (please complete the following information)

  • react-overlays: 5.2.1

Additional context

I work around this issue by using patch-package module with the following patch:

diff --git a/node_modules/@restart/ui/esm/useClickOutside.js b/node_modules/@restart/ui/esm/useClickOutside.js
index 7c8eeb3..63d1db2 100644
--- a/node_modules/@restart/ui/esm/useClickOutside.js
+++ b/node_modules/@restart/ui/esm/useClickOutside.js
@@ -66,7 +66,7 @@ function useClickOutside(ref, onClickOutside = noop, {
     // For things rendered in an iframe, the event might originate on the parent window
     // so we should fall back to that global event if the local one doesn't exist
     // https://github.com/facebook/react/issues/20074
-    let currentEvent = (_ownerWindow$event = ownerWindow.event) != null ? _ownerWindow$event : (_ownerWindow$parent = ownerWindow.parent) == null ? void 0 : _ownerWindow$parent.event;
+    let currentEvent = null; try { currentEvent = (_ownerWindow$event = ownerWindow.event) != null ? _ownerWindow$event : (_ownerWindow$parent = ownerWindow.parent) == null ? void 0 : _ownerWindow$parent.event; } catch {}
     let removeInitialTriggerListener = null;
     if (InitialTriggerEvents[clickTrigger]) {
       removeInitialTriggerListener = listen(doc, InitialTriggerEvents[clickTrigger], handleInitialMouse, true);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions