-
Notifications
You must be signed in to change notification settings - Fork 934
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
Controlled input + reselecting of item issue #163
Comments
I tried reproducing your issue and couldn't. My steps:
I see Perhaps you could try posting the exact options you chose? Or a screen capture? |
Thanks a lot for looking into that! |
Thanks for clearing that up. I see the issue happening now. There are a lot of other things going on here, and I see a lot of other dependencies. Would you please see if you can create a minimal example? If we take out all other dependencies, and we're just working with raw React and downshift, does this problem still happen? This would make it easier to track down the issue. |
Ok so i've stripped it as much as i can Key points to notice:
Further weird behavior of the issue:
Now refresh the page and do the following
Between the different value changes on the above steps you can clearly see a small "flicker" of the value in the input. If you uncommend both event handles for This is a very strange behavior, i'm not sure what to point at. Same as previously, he's a recording showing this (Sorry about the weird overlay that you see there) |
Thanks a lot for doing that. @kentcdodds Can you shed any light on this? I took a stab at looking through the downshift source and it's not immediately clear to me what the issue might be. |
This may be somehow related to facebook/react#4210 or facebook/react#2291 |
Actually, I'm starting to doubt that the issue here is with downshift. If you just type |
Hmmm... Looking at the reproduction it appears to me that you're trying to control the |
@kentcdodds @slavab89 Since this doesn't appear to be an issue with downshift itself, can we close this issue? We would reopen if there is more conclusive evidence that the issue is with downshift. |
Agreed 👍 |
We can continue to chat in here though, if you have more questions about this @slavab89 :) We'll help when we can. |
I've simplified it even further to show you what i mean. I believe that what you did to fix it inside The other "fix" or workaround that i did was listen to the I agree that it is not a bug in downshift but somewhat expected react + browser behavior however strange it may be. |
Ah, I think that I understand what you're trying to accomplish. You just want the input to be cleared whenever the menu is not open right? How's this? |
Interesting!! didnt think about using BTW i didnt say this before but this project is great!! allows for a lot of flexibility and helped me to get the thing i've been trying to do for quite some time: Email input same as gmail (Autocomplete + multi select + editable selected values / tags - the part that's missing in all other select boxes that i've tried) |
That's great! Do you think you could make an example and add it to the list of examples in the README? That'd be awesome. |
So i've started to build something, its kinda a WIP but wanted your input on this. I didnt invest in the UI much so it looks kinda weird but the concept is similar to what react-select is doing. The general concept is to use something similar to the The whole thing contains the most basic functionality so in order to have more features like focusing and overall more UX friendly behavior one would need to add more code. I can add it but i'm not sure if its in the scope. |
This is great! Thanks for your work on it! This is exactly the kind of experience I was hoping to make easier with downshift. I don't think you could build this kind of thing as easily with other autocomplete solutions...
I'm not sure I understand. Everything seems to be functioning fine to me. I don't see anything wrong with this functionally. Could use some clean up from a design perspective, and some accessibility things, but I think it's a great direction! |
Nice! 😄 I'll be able to work on it a bit more close to the weekend so i'll update. |
I've updated the example. Made it a bit more pretty to the eyes and more convenient to use. Myself, i'm using |
It's looking better and better! |
Could you please direct me in what additional things should be done in terms of this example? A material-ui example of this would be great but it will take in a while to get to it i believe + it will be a different example probably. |
I think it looks great! You might just remove the console logs and then make a PR to add it to the list in the README :) |
Oh, also, I'd suggest using match-sorter rather than just the built-in filter. See how to use that in the base example: http://kcd.im/ds-example |
I'm facing same problem, and we already have a lot of code and validation onBlur with setState. Do we have a workaround or fix for this? as i understand onMouseDown will cause a11y issues |
i'm not using downshift, simply react |
downshift
version: 1.3.0I've taken control over the
inputValue
to be able to render the wanted menu items (Somewhat related to my other opened issue).Please open the linked sandbox code and do the following steps:
l
for exampleYou'll see that the input and state returns to the initial selected option (instead of the new one).
Now, uncomment both lines that say
Try to remove
. Includes theonMouseDown
onClick
events and do the above steps once again.You'll notice that the state now changes correctly.
I think it has something to do with the
onBlur
event + react state change that overshadows and cancels the item click event.Reproduction repository:
https://codesandbox.io/s/xy66ml554
Please let me know if you're able to reproduce that.
The text was updated successfully, but these errors were encountered: