mirror of
https://github.com/Choices-js/Choices.git
synced 2024-05-21 06:56:34 +02:00
Minor tweaks
This commit is contained in:
parent
1bc55520e7
commit
d4cf42c33e
4
assets/scripts/dist/bundle.js
vendored
4
assets/scripts/dist/bundle.js
vendored
File diff suppressed because one or more lines are too long
|
@ -329,19 +329,19 @@ export class Choices {
|
|||
});
|
||||
|
||||
if(this.input === document.activeElement) {
|
||||
if(this.input.value) {
|
||||
if(this.input.value && this.input.value.length > 1) {
|
||||
const options = this.getOptionsFiltedBySelectable();
|
||||
const sifter = new Sifter(options);
|
||||
// If we have a value, filter options based on it
|
||||
const handleFilter = debounce(() => {
|
||||
const options = this.getOptionsFiltedBySelectable();
|
||||
const sifter = new Sifter(options);
|
||||
const results = sifter.search(this.input.value, {
|
||||
fields: ['label', 'value'],
|
||||
sort: [{field: 'value', direction: 'asc'}],
|
||||
sort: [{field: 'label', direction: 'asc'}],
|
||||
limit: 10
|
||||
});
|
||||
|
||||
|
||||
this.store.dispatch(filterOptions(results));
|
||||
}, 500)
|
||||
}, 500);
|
||||
|
||||
handleFilter();
|
||||
} else if(hasUnactiveOptions) {
|
||||
|
@ -833,7 +833,7 @@ export class Choices {
|
|||
getOptionsFiltedBySelectable() {
|
||||
const options = this.getOptions();
|
||||
const valueArray = options.filter((option) => {
|
||||
return option.disabled === false;
|
||||
return option.selected === false && option.disabled !== true;
|
||||
},[]);
|
||||
|
||||
return valueArray;
|
||||
|
|
|
@ -45,6 +45,7 @@ const options = (state = [], action) => {
|
|||
const newState = state.map((option, index) => {
|
||||
// Set active state based on whether option is
|
||||
// within filtered results
|
||||
|
||||
option.active = filteredResults.some((result) => {
|
||||
return result.id === index;
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue