react-select: Cannot clear value manually (not truly controlled) when there is no match
It seems that the component is not controlled when the search result is not a match of the options.
Example: https://plnkr.co/edit/b85HMDbt0jUZjkwCE7jG?p=preview
Using 1.0.0-rc.10.
I use the component to do a complex search from a number of filters (react-select being one of them). My external function is unable to clear the component by simply settings value={} to the empty string/undefined/null.
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 1
- Comments: 20 (8 by maintainers)
Hi @zivester you are right it’s never cleared out due to
inputValueis still controlled within theSelectcomponent. This will be a harder bug to fix because we own the state withinputValue.In regards to the value always being an object, you can pass in a
falseyvalue or anobject. Afalseyvalue tells us that the value should be cleared.Hi @zivester the example you gave us includes some incorrect code.
The
onChangehandler should not bebut
The reason is because you are still passing in an object and we don’t do a diff to check if all of the values on the object are empty.
No that doesn’t work. I’ve tried numerous combinations of setting value to
null,undefined, and empty string but none of them work for me. Feel free to play with the plnkr, I’m pretty sure it’s a bug.