mirror of
https://github.com/discourse/discourse.git
synced 2025-05-29 11:48:08 +08:00
DEV: gives sk components a way to trigger a search manually (#9199)
This commit is contained in:
@ -231,10 +231,7 @@ export default Component.extend(
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (this.selectKit.isExpanded) {
|
if (this.selectKit.isExpanded) {
|
||||||
if (this._searchPromise) {
|
this.triggerSearch();
|
||||||
cancel(this._searchPromise);
|
|
||||||
}
|
|
||||||
this._searchPromise = this._searchWrapper(this.selectKit.filter);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.computeContent) {
|
if (this.computeContent) {
|
||||||
@ -388,7 +385,7 @@ export default Component.extend(
|
|||||||
|
|
||||||
_debouncedInput(filter) {
|
_debouncedInput(filter) {
|
||||||
this.selectKit.setProperties({ filter, isLoading: true });
|
this.selectKit.setProperties({ filter, isLoading: true });
|
||||||
this._searchPromise = this._searchWrapper(filter);
|
this.triggerSearch(filter);
|
||||||
},
|
},
|
||||||
|
|
||||||
_onChangeWrapper(value, items) {
|
_onChangeWrapper(value, items) {
|
||||||
@ -567,6 +564,15 @@ export default Component.extend(
|
|||||||
return content;
|
return content;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
triggerSearch(filter) {
|
||||||
|
if (this._searchPromise) {
|
||||||
|
cancel(this._searchPromise);
|
||||||
|
}
|
||||||
|
this._searchPromise = this._searchWrapper(
|
||||||
|
filter || this.selectKit.filter
|
||||||
|
);
|
||||||
|
},
|
||||||
|
|
||||||
_searchWrapper(filter) {
|
_searchWrapper(filter) {
|
||||||
this.clearErrors();
|
this.clearErrors();
|
||||||
this.setProperties({ mainCollection: [], "selectKit.isLoading": true });
|
this.setProperties({ mainCollection: [], "selectKit.isLoading": true });
|
||||||
@ -869,10 +875,7 @@ export default Component.extend(
|
|||||||
this.selectKit.options.filterable || this.selectKit.options.allowAny
|
this.selectKit.options.filterable || this.selectKit.options.allowAny
|
||||||
});
|
});
|
||||||
|
|
||||||
if (this._searchPromise) {
|
this.triggerSearch();
|
||||||
cancel(this._searchPromise);
|
|
||||||
}
|
|
||||||
this._searchPromise = this._searchWrapper();
|
|
||||||
|
|
||||||
this._safeAfterRender(() => {
|
this._safeAfterRender(() => {
|
||||||
this._focusFilter();
|
this._focusFilter();
|
||||||
|
Reference in New Issue
Block a user