From bc303e592a709d3d2e77b898343d4274f536273b Mon Sep 17 00:00:00 2001 From: Anton Korzunov Date: Sun, 9 Jul 2023 16:32:41 +1000 Subject: [PATCH] fix: correct crossframe behavior for Safary, fixes #249 --- CHANGELOG.md | 9 +++++++++ src/Trap.js | 4 ++-- src/util.js | 8 +------- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d576db7..fd66f25 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,12 @@ +## [2.9.4](https://github.com/theKashey/react-focus-lock/compare/v2.9.3...v2.9.4) (2023-02-16) + + +### Bug Fixes + +* update focus-lock to prevent error when accessing cross-origin frames. fixes [#241](https://github.com/theKashey/react-focus-lock/issues/241) ([6633d2b](https://github.com/theKashey/react-focus-lock/commit/6633d2bed7f61fe1b6ca9a573331568bbd0b63af)) + + + ## [2.9.3](https://github.com/theKashey/react-focus-lock/compare/v2.9.2...v2.9.3) (2023-01-28) diff --git a/src/Trap.js b/src/Trap.js index 7933084..d10d07a 100644 --- a/src/Trap.js +++ b/src/Trap.js @@ -182,9 +182,9 @@ FocusTrap.propTypes = { const onWindowBlur = () => { focusWasOutsideWindow = 'just'; // using setTimeout to set this variable after React/sidecar reaction - setTimeout(() => { + deferAction(() => { focusWasOutsideWindow = 'meanwhile'; - }, 0); + }); }; const attachHandler = () => { diff --git a/src/util.js b/src/util.js index 7521a0a..c11da39 100644 --- a/src/util.js +++ b/src/util.js @@ -1,11 +1,5 @@ export function deferAction(action) { - // Hidding setImmediate from Webpack to avoid inserting polyfill - const { setImmediate } = window; - if (typeof setImmediate !== 'undefined') { - setImmediate(action); - } else { - setTimeout(action, 1); - } + setTimeout(action, 1); } export const inlineProp = (name, value) => {