DEV: gives sk components a way to trigger a search manually (#9199)

This commit is contained in:
Joffrey JAFFEUX 2020-03-13 12:41:08 +01:00 committed by GitHub
parent ac8d8e3b62
commit b727e39a42
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 12 additions and 9 deletions

View File

@ -231,10 +231,7 @@ export default Component.extend(
});
if (this.selectKit.isExpanded) {
if (this._searchPromise) {
cancel(this._searchPromise);
}
this._searchPromise = this._searchWrapper(this.selectKit.filter);
this.triggerSearch();
}
if (this.computeContent) {
@ -388,7 +385,7 @@ export default Component.extend(
_debouncedInput(filter) {
this.selectKit.setProperties({ filter, isLoading: true });
this._searchPromise = this._searchWrapper(filter);
this.triggerSearch(filter);
},
_onChangeWrapper(value, items) {
@ -567,6 +564,15 @@ export default Component.extend(
return content;
},
triggerSearch(filter) {
if (this._searchPromise) {
cancel(this._searchPromise);
}
this._searchPromise = this._searchWrapper(
filter || this.selectKit.filter
);
},
_searchWrapper(filter) {
this.clearErrors();
this.setProperties({ mainCollection: [], "selectKit.isLoading": true });
@ -869,10 +875,7 @@ export default Component.extend(
this.selectKit.options.filterable || this.selectKit.options.allowAny
});
if (this._searchPromise) {
cancel(this._searchPromise);
}
this._searchPromise = this._searchWrapper();
this.triggerSearch();
this._safeAfterRender(() => {
this._focusFilter();