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

defaultValue not selecting the value, dropdown box remains open #151

Open
benrlodge opened this issue Dec 14, 2015 · 7 comments
Open

defaultValue not selecting the value, dropdown box remains open #151

benrlodge opened this issue Dec 14, 2015 · 7 comments
Labels

Comments

@benrlodge
Copy link
Contributor

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.

@benrlodge
Copy link
Contributor Author

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.

@benrlodge benrlodge changed the title defaultValue not selecting one value if other fuzzy matches exist defaultValue not selecting the value, dropdown box remains open Dec 14, 2015
@benrlodge
Copy link
Contributor Author

@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});
  }

@ragebiswas
Copy link

+1 for this. @benrlodge is there any way without modifying the source code? :(

@benrlodge
Copy link
Contributor Author

'fraid not from what I can tell. I'm working off a forked version in the mean time.

@benrlodge
Copy link
Contributor Author

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

@nosilleg
Copy link
Contributor

nosilleg commented Apr 2, 2016

@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?

@benrlodge
Copy link
Contributor Author

i'm only using Typeahead @nosilleg

As fmoo mentioned, it's the same issue noted here #21 (i just didn't discover that when posting this issue)

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

No branches or pull requests

4 participants