react-select-search icon indicating copy to clipboard operation
react-select-search copied to clipboard

Select doesn't close on click to it

Open TonyCh55 opened this issue 3 years ago • 4 comments
trafficstars

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

TonyCh55 avatar Jul 12 '22 10:07 TonyCh55

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>}

adiled avatar Aug 10 '22 10:08 adiled

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;
}

fmmajd avatar Feb 09 '23 14:02 fmmajd

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

CallumJHays avatar Mar 26 '23 06:03 CallumJHays

.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.

kevincompton avatar Jul 04 '23 03:07 kevincompton