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

Allow value to be changed from higher level #108

Open
danieljuhl opened this issue Jul 29, 2015 · 10 comments
Open

Allow value to be changed from higher level #108

danieljuhl opened this issue Jul 29, 2015 · 10 comments

Comments

@danieljuhl
Copy link

It seems that value is only used on component construction, and not respected if changed afterwards.

I would like to be able to change the value / default value of the component based on an external value.

@yurynix
Copy link

yurynix commented Aug 10, 2015

I had a similar scenario where I would render typehead with different value when user clicked on something, so I've made the following modification that seems to work for me:
yurynix@1a96381

@barbalex
Copy link

@yurynix did you make a pull request? I need this feature too. For instance to empty the input when the user clicks on an x symbol at it's right side

@yurynix
Copy link

yurynix commented Aug 24, 2015

@barbalex
I don't mind making a pull request, but I'm looking for getting some feedback first,
Since I'm not yet very familiar with TypeAhead's inner stuff.

Same issue discussed here: #74

@RobbieClarken
Copy link

@yurynix Your proposed change would be very useful for me too. I wish I could provide feedback but I'm not familiar enough with the module either.

@smith-kyle
Copy link

#133 Seems to solve a niche problem. If value could instead be modified directly through the props then you could do all this from the Typeahead parent component.

@yurynix
Copy link

yurynix commented Oct 10, 2015

@smith-kyle
Typeahead already has all the mechanics: finding object by value, converting object to display value, so we might as well let Typeahead handling choosing the right object by value at props.

As you can see from the commit, the code change is very minor.

@danieljuhl
Copy link
Author

@yurynix I've been testing you change, which works great in our setup, but I made two minor changes. First I allowed to clear the typeahead by passing a falsy value to Typeahead, furthermore I modified the selection, so that it does not check for only one result, but instead it checks if the first option is equal to the input value. The reason for this is that even when the input value is an exact match, the fuzzy search can suggest other results, and I think that setting the value programmatic, should not be a fuzzy pick. I also look to make a change, so that the defaultValue can be used instead, and in that case only updates the value if the user has not made any typing.

@yurynix
Copy link

yurynix commented Oct 10, 2015

@danieljuhl Sounds great, can you provide a link for your changes?

@danieljuhl
Copy link
Author

@yurynix https://github.com/kodyl/react-typeahead/tree/react-0.14, but please notice that I also made changes to avoid errors and warnings when used with [email protected] - it was actually the main goal

@yurynix
Copy link

yurynix commented Oct 12, 2015

@danieljuhl Thanks!

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

5 participants