Skip to content

Commit

Permalink
loading spinner should show when preload=focus. fixes #185
Browse files Browse the repository at this point in the history
  • Loading branch information
oyejorge committed Aug 24, 2021
1 parent 0d54a75 commit 7f90d22
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
11 changes: 6 additions & 5 deletions src/tom-select.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1432,14 +1432,15 @@ export default class TomSelect extends MicroPlugin(MicroEvent){
}
return content;
};

// invalid query
if( !self.settings.shouldLoad.call(self,query) ){
add_template('not_loading');


// add loading message
}else if( self.loading ){
if( self.loading ){
add_template('loading');

// invalid query
}else if( !self.settings.shouldLoad.call(self,query) ){
add_template('not_loading');

// add no_results message
}else if( results.items.length === 0 ){
Expand Down
4 changes: 3 additions & 1 deletion test/tests/config-load.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ describe('load', function() {
assert.equal(query, '');
setTimeout(function() {
load_cb([{value: 'c', text: 'C'}]);
});
},100);
}
});

Expand All @@ -21,6 +21,8 @@ describe('load', function() {
});

await asyncClick(test.instance.control);
assert.isOk(test.instance.dropdown.querySelector('.spinner'));

await waitFor(300);
assert.equal(calls_focus, 1);
assert.equal(calls_load, 1);
Expand Down

0 comments on commit 7f90d22

Please sign in to comment.