Skip to content

Country selection doesn't work in the shadow DOM #710

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

Open
traianturcu opened this issue Mar 24, 2025 · 0 comments
Open

Country selection doesn't work in the shadow DOM #710

traianturcu opened this issue Mar 24, 2025 · 0 comments

Comments

@traianturcu
Copy link

I am using react-phone-input-2 in the shadow DOM.

If I click on the country dropdown, it shows up and I am able to select a country using the keyboard (arrow up, down, ENTER).
However, if I am trying to use the mouse, the dropdown closes (whether I try to select a country or to drag the scroll bar).

The only solution that fixes this is to disable enableClickOutside

based on this I think the problem comes from this part of the code:

    if (document.addEventListener && this.props.enableClickOutside) {
      document.addEventListener('mousedown', this.handleClickOutside);
    }

I'm not sure if there is any potential solution to maybe provide another prop with the shadowRoot so that the event listener can be attached to it, rather than the document , if it's provided?

Thank you!

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

No branches or pull requests

1 participant