Skip to content

Commit

Permalink
Fixes Autocomplete error when provided value prop that is not in sour…
Browse files Browse the repository at this point in the history
…ce option while preserving value text
  • Loading branch information
CP-zweiler committed Aug 7, 2016
1 parent a825208 commit 0bce911
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
9 changes: 7 additions & 2 deletions components/autocomplete/Autocomplete.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,13 @@ const factory = (Chip, Input) => {
}

query (key) {
return !this.props.multiple && key ? this.source().get(key) : '';
}
var query_value = '';
if(!this.props.multiple && key) {
var source_value = this.source().get(key)
query_value = source_value ? source_value : key;
}
return query_value;
}

suggestions () {
let suggest = new Map();
Expand Down
9 changes: 7 additions & 2 deletions lib/autocomplete/Autocomplete.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,13 @@ var factory = function factory(Chip, Input) {
}, {
key: 'query',
value: function query(key) {
return !this.props.multiple && key ? this.source().get(key) : '';
var query_value = '';
if(!this.props.multiple && key) {
var source_value = this.source().get(key)
query_value = source_value ? source_value : key;
}
return query_value;
}
}, {
key: 'suggestions',
value: function suggestions() {
Expand Down Expand Up @@ -474,4 +479,4 @@ var factory = function factory(Chip, Input) {
var Autocomplete = factory(_Chip2.default, _Input2.default);
exports.default = (0, _reactCssThemr.themr)(_identifiers.AUTOCOMPLETE)(Autocomplete);
exports.autocompleteFactory = factory;
exports.Autocomplete = Autocomplete;
exports.Autocomplete = Autocomplete;

0 comments on commit 0bce911

Please sign in to comment.