everweij / react-laag

Hooks to build things like tooltips, dropdown menu's and popovers in React
https://www.react-laag.com
MIT License
907 stars 47 forks source link

Ability to pass custom window/document instances #19

Closed anilanar closed 4 years ago

anilanar commented 4 years ago

When rendering into iframes/shadow-dom, global window and document refer to different instances than those that are rendered in. A similar capability to downshift's environment prop is needed.

everweij commented 4 years ago

Hi Anil, thanks for reporting this issue! Interesting point, I haven't encountered a scenario where I needed the feature you propose, but I'm cool with implementing it. Will make a draft as soon as I have time!

anilanar commented 4 years ago

Cool thanks. Our scenario is rendering “widgets” into iframes (<Frame>Hello world</Frame>) to avoid CSS side effects from parent websites. That’s a very niche requirement; but lucky for us, emotion/styled-components also supports it.

everweij commented 4 years ago

Hi, I created a draft for the environment prop in v1.6.0. See https://react-laag.com/docs/togglelayer/#environment . Can you check if this works for you?

chrissysemens commented 1 year ago

Hi all,

I'm sturggling to get the environment property to work. I've got a window instance and passing the window to the environment prop. But the layers div still is always rendered within the base page that opens the new window.

Am I missing something? Any help appreciated.