fmoo / react-typeahead

Pure react-based typeahead and typeahead-tokenizer
ISC License
677 stars 231 forks source link

Documentation about `defaultValue` and `allowCustomValues` #73

Open franleplant opened 9 years ago

franleplant commented 9 years ago

Hi! What is the function of these? Are included in the latest release? I've tested defaultValue and it is not working on 1.0.4.

Any quick ideas about them?

Thanks! Fran

thehuey commented 9 years ago

I think defaultValue serves to have the tokenizer check and display values that partially match. It makes the TypeAheadSelector display if you have matching values in the options array.

On Fri, May 8, 2015 at 3:40 PM, Francisco Guijarro <notifications@github.com

wrote:

Hi! What is the function of these? Are included in the latest release? I've tested defaultValue and it is not working on 1.0.4.

Any quick ideas about them?

Thanks! Fran

— Reply to this email directly or view it on GitHub https://github.com/fmoo/react-typeahead/issues/73.

franleplant commented 9 years ago

With string literals it works:

defaultValue="something"

but with bindings it does not

defaultValue={this.state.someVar}

fmoo commented 9 years ago

but with bindings it does not

defaultValue={this.state.someVar}

Is this.state.someVar set to a string? That should be working. Are you getting an error message?

franleplant commented 9 years ago

@fmoo no error message, just nothing is displayed on the input inside the typeahead

Originally someVar has nothing and after a couple of seconds it gets a string value.

This does not work either:

{"some string"}
fmoo commented 9 years ago

This is really strange. Were you using the latest version of react everywhere in your project?

danielsoner commented 9 years ago

Hi, I use React 0.14.0-alpha3 and I have the same exact problem.

jprogertest commented 9 years ago

The same here with React 0.13.3. A basic workaround that partially works for me : <Input type='text' id='ShortName' placeholder='Enter short name' defaultValue={${this.state.ShortName}} /> But it does not refresh the value when setState({ShortName: 'toto'}) is called in success of an ajax call. Any idea ?

kitdesai commented 8 years ago

having this same issue:

defaultValue={selectedCity} doesn't work for me but defaultValue="asdf" does. also weird is that placeholder={selectedCity} works correctly but with bindings defaultValue (and value) do not

EDIT: @fmoo, figured out the issue. this.props.entryValue is what's being passed to the input element's value attribute, but that's set in getInitialState(), which won't get overridden if the typeahead component is re-rendered with an updated value or defaultValue.

the issue is being addressed here: https://github.com/fmoo/react-typeahead/pull/133