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

menuShouldBlockScroll not working properly when the select is mounted in a separate window but execution context is in main window #5346

Closed
aszmyd opened this issue Sep 16, 2022 · 0 comments · Fixed by #5347
Labels
issue/bug-unconfirmed Issues that describe a bug that hasn't been confirmed by a maintainer yet

Comments

@aszmyd
Copy link
Contributor

aszmyd commented Sep 16, 2022

Are you reporting a bug or runtime error?

A bug.
react-select version 5.4.0

I have an app that uses React Portals to mount components in separate windows/popups (we use react-new-window
package to achieve that.

The thing is that in such a use case, the markup and components are rendered in the external HTML page (popup) but the javascript execution context is still in the main window so referring objects like window or document could produce errors because the document on the external page (where the component is rendered) is different than the one where the javascript executes.

One example of such an issue is when we use menuShouldBlockScroll config. When it's used, the library adds a fixed positioned element to the page and attaches onClick event on it to blur the select. The issue is that the event listener looks for document.activeElement which is wrong in my use case as it refers to the main document, not the popup one where the component is mounted.

I found a simple solution for that one and will push a pull request with it soon.

@aszmyd aszmyd added the issue/bug-unconfirmed Issues that describe a bug that hasn't been confirmed by a maintainer yet label Sep 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
issue/bug-unconfirmed Issues that describe a bug that hasn't been confirmed by a maintainer yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant