Minor tweaks

This commit is contained in:
Josh Johnson 2018-05-29 20:30:58 +01:00
parent 5640744bf3
commit 3886cbbd5c

View file

@ -862,10 +862,9 @@ class Choices {
// Add each result as a choice // Add each result as a choice
parsedResults.forEach(result => { parsedResults.forEach(result => {
if (result.choices) { if (result.choices) {
const groupId = result.id || null;
this._addGroup({ this._addGroup({
group: result, group: result,
id: groupId, id: result.id || null,
valueKey: value, valueKey: value,
labelKey: label, labelKey: label,
}); });
@ -904,9 +903,7 @@ class Choices {
// If new value matches the desired length and is not the same as the current value with a space // If new value matches the desired length and is not the same as the current value with a space
const haystack = this._store.searchableChoices; const haystack = this._store.searchableChoices;
const needle = newValue; const needle = newValue;
const keys = isType('Array', this.config.searchFields) const keys = [...this.config.searchFields];
? this.config.searchFields
: [this.config.searchFields];
const options = Object.assign(this.config.fuseOptions, { keys }); const options = Object.assign(this.config.fuseOptions, { keys });
const fuse = new Fuse(haystack, options); const fuse = new Fuse(haystack, options);
const results = fuse.search(needle); const results = fuse.search(needle);