defaultValue not selecting the value, dropdown box remains open
When I use defaultValue if there is a fuzzy match, it does not select the matching value, but instead shows the matching options (as if you typed in the value). I may be able to look into submitting a PR if this isn't already being worked on.
actually, i'm seeing the drop-down remain open even if I have a single match. Not sure if this is by design, but I would prefer, or at least have the option, to have the default value pre-selected.
@fmoo not sure if it's the best approach, but I have something working where I check if this.props.defaultValue exists as well as a hasRendered flag (could be a better word for this...) which will be false on first run, then flip it true when the user first starts to interact with the input box again at _onTextEntryUpdated.
// added:
_renderIncrementalSearchResults: function() {
// A default value was passed in
if (this.props.defaultValue && !this.state.hasRendered) {
return "";
}
_onTextEntryUpdated: function() {
var value = this.refs.entry.getDOMNode().value;
this.setState({visible: this.getOptionsForValue(value, this.props.options),
selection: null,
selectionIndex: 0,
hasRendered: true, // <-- added
entryValue: value});
}
+1 for this. @benrlodge is there any way without modifying the source code? :(
'fraid not from what I can tell. I'm working off a forked version in the mean time.
~~This could be a separate issue - but related - I'm also realizing it would be helpful to have some kind of currentValue option that can be accessed at componentWillReceiveProps, as I'm trying to implement routing with default values that would be pre-selected based on the routers params.~~
my bad. didnt see props.value
@benrlodge I'm coming to this from #176
What's the use case here? Is this something that Tokenizer defaultSelected doesn't solve? Are you only using Typeahead and not Tokenizer?
i'm only using Typeahead @nosilleg
As fmoo mentioned, it's the same issue noted here https://github.com/fmoo/react-typeahead/issues/21 (i just didn't discover that when posting this issue)