mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: ensures scoped search category is searching in all categories (#9031)
This commit is contained in:
parent
832a0e410a
commit
f336aeee6f
@ -66,15 +66,7 @@ export default ComboBoxComponent.extend({
|
|||||||
|
|
||||||
search(filter) {
|
search(filter) {
|
||||||
if (filter) {
|
if (filter) {
|
||||||
let content = this.content;
|
return this.content.filter(item => {
|
||||||
|
|
||||||
if (this.selectKit.options.scopedCategoryId) {
|
|
||||||
content = this.categoriesByScope(
|
|
||||||
this.selectKit.options.scopedCategoryId
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return content.filter(item => {
|
|
||||||
const category = Category.findById(this.getValue(item));
|
const category = Category.findById(this.getValue(item));
|
||||||
const categoryName = this.getName(item);
|
const categoryName = this.getName(item);
|
||||||
|
|
||||||
@ -93,8 +85,12 @@ export default ComboBoxComponent.extend({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
content: computed("selectKit.options.scopedCategoryId", function() {
|
content: computed("selectKit.{filter,options.scopedCategoryId}", function() {
|
||||||
return this.categoriesByScope(this.selectKit.options.scopedCategoryId);
|
if (!this.selectKit.filter && this.selectKit.options.scopedCategoryId) {
|
||||||
|
return this.categoriesByScope(this.selectKit.options.scopedCategoryId);
|
||||||
|
} else {
|
||||||
|
return this.categoriesByScope();
|
||||||
|
}
|
||||||
}),
|
}),
|
||||||
|
|
||||||
categoriesByScope(scopedCategoryId = null) {
|
categoriesByScope(scopedCategoryId = null) {
|
||||||
|
@ -52,11 +52,15 @@ componentTest("with scopedCategoryId", {
|
|||||||
"My idea here is to have mini specs for features we would like built but have no bandwidth to build"
|
"My idea here is to have mini specs for features we would like built but have no bandwidth to build"
|
||||||
);
|
);
|
||||||
assert.equal(this.subject.rowByIndex(1).value(), 26);
|
assert.equal(this.subject.rowByIndex(1).value(), 26);
|
||||||
assert.equal(this.subject.rows().length, 2);
|
assert.equal(this.subject.rows().length, 2, "default content is scoped");
|
||||||
|
|
||||||
await this.subject.fillInFilter("spec");
|
await this.subject.fillInFilter("bug");
|
||||||
|
|
||||||
assert.equal(this.subject.rows().length, 1);
|
assert.equal(
|
||||||
|
this.subject.rowByIndex(0).name(),
|
||||||
|
"bug",
|
||||||
|
"search finds outside of scope"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user