Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use provided browsing context #149

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

martin-pettersson
Copy link

I ran into a scenario where I needed to use this library in a popup window and the easiest solution was to render the component using a React portal. The issue then was that this library was listening for events on the "origin" window object instead of the popup window.

If we allow users to pass in a custom browsing context as a prop it's fairly easy to solve this issue. Here's a trivial example with some sudo-ish code to illustrate the solution.

const browsingContext = window.open("", "", "popup");

return createPortal(
    <MapInteractionCSS browsingContext={browsingContext} ...>
        ...
    </MapInteractionCSS>,
    browsingContext.document.body
);

Since we fall back to the global window object if no browsing context is provided this won't break anything.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant