Skip to content

Use provided browsing context#149

Open
martin-pettersson wants to merge 1 commit intostrateos:masterfrom
martin-pettersson:master
Open

Use provided browsing context#149
martin-pettersson wants to merge 1 commit intostrateos:masterfrom
martin-pettersson:master

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