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

Select doesn't close on click to it #242

Open
TonyCh55 opened this issue Jul 12, 2022 · 4 comments
Open

Select doesn't close on click to it #242

TonyCh55 opened this issue Jul 12, 2022 · 4 comments

Comments

@TonyCh55
Copy link

TonyCh55 commented Jul 12, 2022

When click on select it opens and when to click it again it doesn't close

But in storybook demos this functionality works properly
Help please

@adiled
Copy link

adiled commented Aug 10, 2022

Anyone facing this, remove multiple option form your props, and also make sure if you're using a custom renderOption, the first parameter is props that you need to forward like so:

renderOption={(props, optionData, { highlighted, selected }) => <li {...props}>...</li>}

@fmmajd
Copy link

fmmajd commented Feb 9, 2023

For anyone else having the same problem in the future, it's not a js issue. it's a CSS issue. You can add this to have "close on blur" functionality:

.form-group-container:not(.form-group-has-focus) .form-group-select {
  display: none;
}

@CallumJHays
Copy link

CallumJHays commented Mar 26, 2023

To add to @fmmajd 's answer, to get this working with css modules, you need to supply definitions for the classes .has-focus and .select, even if empty.

/* yourReactSelectSearch.module.css */

/* required even if empty, otherwise classnames are never assigned */
.container {}
.has-focus {}
.select {}

.container:not(.has-focus) .select {
    display: none;
}

It appears that the example default style.module.css is out of date

@kevincompton
Copy link

kevincompton commented Jul 4, 2023

.form-group-container:not(.form-group-has-focus) .form-group-select {
  display: none;
}

this fixed my issue and I find this pretty janky, shouldn't take all this research to get it to look like the demo. Also I would encourage the devs to have this work with tailwind.

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

5 participants