Skip to content
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

Using setEntryText or setting a typeahead's entryValue state variable with a ref/from outside the typeahead component has unwanted side effects #181

Open
vrunjeti opened this issue Apr 12, 2016 · 1 comment

Comments

@vrunjeti
Copy link
Contributor

I'm trying to set the value of the typeahead's input, but doing so with setEntryText or setting its entryValue state also renders the dropdown with one option containing the chosen value.

The solution suggested in #116 works for setting the input's value, but doing so also displayed the dropdown containing one option with that value. This brought up further issues with trying to manually blur the input. Unlike the solution from #169, which depends on re-rendering the typeahead component from the top, in this case, calling typeahead.setEntryText or setting its entryValue state variable seems to also trigger something that causes the results dropdown to be displayed.

What I'm wondering is if this coupling was intentional, and if so, why. I would imagine that most people trying to use setEntryText would want to do just that and not have any side effects.

After some more digging around, I found that @yurynix's suggestion from #74 achieves what I'm trying to do with no side effects. Even though this worked for me, I'm still curious about setEntryText's side effects, especially since it doesn't appear to be mentioned in the docs.

Sorry for all these words, I'm just trying to get a better understanding and hopefully help others find solutions to similar problems. Thanks!

@vrunjeti
Copy link
Contributor Author

Update: I'm not so sure anymore if those side effects are a result of setEntryText. It might have been an issue with my code (oops). However, I'm still curious if anyone has this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant