Giter Club home page Giter Club logo

Comments (7)

theKashey avatar theKashey commented on September 27, 2024 1

Released as v2.9.5.

Change is not yet propagated to https://github.com/theKashey/react-focus-on, please help me understand theKashey/react-focus-on#74 (comment) first

from react-focus-lock.

theKashey avatar theKashey commented on September 27, 2024

bug confirmed 😭

from react-focus-lock.

cee-chen avatar cee-chen commented on September 27, 2024

Thanks for the quick repro Anton!

Not sure if this is helpful or not, but @tkajtoch and I were testing crossFrame in react-focus-on locally in our codebase's Storybook, and were also getting that same behavior as well even in Chrome and FF and couldn't figure out why or what was happening (code was almost identical to the above CodeSandbox). We eventually figured out it was the setTimeout 0 in onWindowBlur race condition:

https://github.com/theKashey/react-focus-lock/blob/master/src/Trap.js#L185-L187

We changed the above setTimout duration from 0 to 1 and the crossFrame behavior started working for us locally. Maybe give it a shot on your end and see if it fixes Safari behavior as well? 🤞

from react-focus-lock.

theKashey avatar theKashey commented on September 27, 2024

😲 onBlur is executed "a little later" using a deferAction helper of mine - https://github.com/theKashey/react-focus-lock/blob/master/src/util.js#L7
It works exactly via setTimeout(..,1) - you have found the root case.
Well, it uses setTimeout only in the absence of setImmediate, which may or may not be polyfilled by a bundler.

from react-focus-lock.

cee-chen avatar cee-chen commented on September 27, 2024

Oooh! It all makes sense now 🤦 All the credit goes to @tkajtoch for figuring out that changing setTimeout fixed the behavior!

Would changing onWindowBlur to use deferAction be a clean solution, or would just changing the 0 to a 1 on its timeout suffice? 🤔

from react-focus-lock.

theKashey avatar theKashey commented on September 27, 2024

deferAction is a way to go. Tested in Chrome and safari - works great.

from react-focus-lock.

cee-chen avatar cee-chen commented on September 27, 2024

I think @tkajtoch is working on that - will keep you posted! Thanks as always for being amazingly responsive and speedy Anton!

from react-focus-lock.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.