-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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 clear value manually (not truly controlled) when there is no match #2155
Comments
Hi @zivester value should be a |
No that doesn't work. I've tried numerous combinations of setting value to |
@zivester can you confirm whether this is fixed by #2179? preview here: https://deploy-preview-2179--react-select.netlify.com/ |
Doesn't seem to be working for this bug. It doesn't ever seem to clear the display "label" value, but it does clear the
I'm not sure what is desired with the new I also wasn't sure how to use the preview you linked, so I just tested locally with |
Hi @zivester the example you gave us includes some incorrect code. The
but
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. |
@agirton I've tried all permutations, here's one using your example: https://plnkr.co/edit/OGimFuPvqMfPHEk5FxWt?p=preview As you'll see, the I can't find the old migration docs, but I believe they referenced |
Hi @zivester you are right it's never cleared out due to In regards to the value always being an object, you can pass in a |
Hi, |
I can't type more than one character into the field with that fix @yuri-sakharov |
Can you provide code example? Because it works fine in my project with this fix. import './App.css'; const value = {value: {label: 'a1', value: 'b1'}};
handleClear(){
} export default App; |
I've provided two plnkr's in this commit that you're free to alter. The clearing works with your commit, but the controlled portion of it does not. When you type more than a single letter into the component the value is cleared. The check you've put in place is too broad, and I believe too trivial based off of what @agirton is describing. |
also I copied your code(from top message) as is to my and it woks fine. I use react 16.1.1 and 16.2.0. Please watch attached video. |
Can you please provide a plnkr/demo of some kind? I can then attempt to show you were it doesn't work on your branch. I can't really do much with a video unfortunately. Also its already apparent that the x button is not clearing correctly as well. |
I does'n know how to add my code from this branch with my fix to plnkr/demo |
I also tried your code from second link on my local draft and it works pretty well with small fix: |
@zivester thanks for this issue, unfortunately there's no clean way to give you direct control of the inputValue in state by changing the value prop. This is something we're actively looking to address in future releases. In the meantime, I've added an internal setInputChange method to the Select component. This takes a string argument, calls the onInputChange prop if one exists, and sets the inputvalue in state to the passed in string argument. You can access this by accessing the ref of the Select component. The implementation PR can be found here, please also see the updated 'States' example for an example of how to use this. |
@gwyneplaine thank you for the workaround, that does indeed allow me to programmatically reset it. Unfortunately it introduced the issue #2299 for me, so I'll have to wait until that PR is merged. |
same here |
Hello - In an effort to sustain the We understand this might be inconvenient but in the best interest of supporting the broader community we have to direct our limited efforts to maintain the latest version. If you aren't using the latest version of However, if you feel this issue / pull request is still relevant and you'd like us to review it - please leave a comment and we'll do our best to get back to you! |
Try using the key prop for the Select component. This will re-render the component. Works for me. |
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 settingsvalue={}
to the empty string/undefined/null.The text was updated successfully, but these errors were encountered: