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

Cannot select same option for multiple dropdowns #142

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

ledenis
Copy link
Contributor

@ledenis ledenis commented Dec 3, 2022

It fails to select the same option when there is multiple dropdowns.

It seems that getReactSelectContainerFromInput goes to far in the ancestor tree. When trying to click on the option, it sees the text from the other dropdown.

@ledenis
Copy link
Contributor Author

ledenis commented Dec 3, 2022

Note: I did not add a fix. I only added a failing test (inspired from #47 )

@romgain
Copy link
Owner

romgain commented Dec 3, 2022

Thanks a lot for reporting this @ledenis !

Would you be able to contribute a fix?
Thank you!

@ledenis
Copy link
Contributor Author

ledenis commented Dec 3, 2022

I was thinking about it, not sure if I can find a reliable fix. I saw that an attempt has been made to improve getReactSelectContainerFromInput but it caused bugs then reverted : #86

Meanwhile, I found a workaround: pass a custom container

    await selectEvent.select(mondayInput, "Chocolate", {
      container: () => mondayInput.closest('[class$="-container"]')!,
    });

A similar approach was found by someone else: https://stackoverflow.com/questions/70018351/react-select-event-doesnt-trigger-the-onchange-function-to-set-the-value-during

@ledenis
Copy link
Contributor Author

ledenis commented Dec 3, 2022

I pushed a fix 🎉

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.

2 participants