Skip to content

Commit

Permalink
fix: avoid focusing already removed iframe(closes #2178)
Browse files Browse the repository at this point in the history
  • Loading branch information
Artem-Babich committed Mar 28, 2022
1 parent 57c57f6 commit 4a9cd8f
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/client/sandbox/event/focus-blur.ts
Expand Up @@ -291,6 +291,11 @@ export default class FocusBlurSandbox extends SandboxBase {
!styleUtils.isElementInInvisibleIframe(el);
const elDocument = (el[INTERNAL_PROPS.processedContext] || this.window).document;

// NOTE: In some cases focus event can be raised for the element in the iframe at the moment when the iframe is removed from the document.
// For example, in React application by its internal mechanism: https://github.com/DevExpress/testcafe-hammerhead/issues/2178
if(!elDocument.defaultView)
return null;

if (!raiseEventInIframe || isNativeFocus && !styleUtils.isElementVisible(el, elDocument))
return null;

Expand Down

1 comment on commit 4a9cd8f

@nottoseethesun
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yay!

Please sign in to comment.