Comments (7)
Correct. And later it used in react-focus-lock
as const isFreeFocus = () => focusOnBody() || focusIsHidden();
which is later used in a little complicated condition - https://github.com/theKashey/react-focus-lock/blob/master/src/Trap.js#L100
It's more that possible that you trigger other parts of it. That would be interesting to know what exactly is happening, but there is only one way it should work – if as per documentation and my own understanding no-focus-lock
means no-focus-lock
, then it should be so.
I'll correct code.
from react-focus-lock.
👋 hello Julia. This is another reminder how bad I am with the documentation 😭
Anyway - your issue seems to be quite close to #213. Here what you can do:
- add
data-no-focus-lock
on your iframe (documented at https://github.com/theKashey/focus-lock#focus-fighting), this will focus operations within marked location without triggering the lock. - as you might note - this attribute is quite specific to focus-lock library, so I might propose a little more complicated solution. But I am really not sure if you able to use it or not - "focus fighting"
The idea is following
- when you want to display your experience - focus it, I hope you already doing that following a11y guidelines.
- focus-lock will steal your focus back
- so you focus it again :)
- focus-lock will surrender - https://github.com/theKashey/focus-lock/blob/master/src/setFocus.ts#L55
This is not something ease to implement:
- you need to add
blur
event to your iframe- focus iframe onblur
- focus iframe
- focus-lock will steal focus
- onblur event will put it back
- focus-lock will detect focus-fighting and self-disable
- remove onblur event
This is all I can help with. Good luck.
from react-focus-lock.
Hi, thanks a lot for the advice! It seems the data-no-focus-lock
only works if we add the package to our repo, which is sadly not an option so I'll see if I can do the focus fighting. Thanks again!
from react-focus-lock.
data-no-focus-lock
is an html attribute and does not need anything except it to be added. No javascript should be involved at all.
from react-focus-lock.
Oh uhm then for some reason it's not working (I tried adding this attribute to our iframe but it didn't fix the problem).
from react-focus-lock.
Looking at the source code, it would seem this attribute is saved in a constant called FOCUS_ALLOW
which is only used inside a function called focusIsHidden
, but I couldn't find anywhere in the code (except tests) where this function was used. If it's not too much to ask, could you double-check that you're actually using this function somewhere? I'm trying to understand why it's not working for us. Thanks again!
from react-focus-lock.
This issue has been marked as "stale" because there has been no activity for 2 months. If you have any new information or would like to continue the discussion, please feel free to do so. If this issue got buried among other tasks, maybe this message will reignite the conversation. Otherwise, this issue will be closed in 7 days. Thank you for your contributions so far.
from react-focus-lock.
Related Issues (20)
- Socket dev picking up some security issues. HOT 3
- Add an `onError` callback for when focus fighting is detected HOT 2
- Feature request - Clickaway deactivation HOT 2
- `crossFrame={false}` has cross-browser Safari issues HOT 7
- Can't click without scroll being changed HOT 3
- Invalid hook call when using it inside a library HOT 3
- Issue with importing FocusLock component HOT 18
- /*#__PURE__*/ comment throws warning in Rollup HOT 3
- Unclear behavior during loosing focus in unmanaged area HOT 3
- Migrate to Typescript HOT 1
- Remove sidecar HOT 1
- useFocusLock HOT 1
- Version `2.11.0` doesn't compile with TS HOT 1
- Returning focus to element inside an iframe HOT 2
- ESM compatibility breaks WebPack build HOT 16
- added file extension in imports as it was breaking in webpack 5 HOT 2
- version 2.12.0 , feature "ESM Compatible" breaks React app CRA build with Chackra UI HOT 3
- Module Resolution Error: Missing File Extensions in Import Statements HOT 2
- Typo in readme HOT 2
- onDeactivation callback is called on render in StrictMode HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-focus-lock.