JedWatson / react-select

The Select Component for React.js
https://react-select.com/
MIT License
27.63k stars 4.13k forks source link

Menu closes if value is changed outside with onChange Callback. #4766

Closed RustamKarimov3 closed 3 years ago

RustamKarimov3 commented 3 years ago

"react-select": "4.3.1",

I try to implement multiselect component with react-select and when I attempt to prevent closing menu on option select with closeMenuOnSelect={false} one closes anyway when value is changed with onChange callback.

const [value, setValue] = useState();

 <ReactSelect<SelectOption<T>>
        innerRef={ref}
        closeMenuOnSelect={false}
        id={id}
        tabIndex={`${tabIndex}`}
        onChange={setValue}
        value={value}
        defaultValue={defaultValueFromOuterState}
        options={options}
      />
RustamKarimov3 commented 3 years ago

upd

Menu closes on any rerender even if I don't pass onChange or value prop to ReactSelect component

RustamKarimov3 commented 3 years ago

I am stupid, this was storybook problem