FIX: Improve quick search speed and result highlights (#14610)
This commit is contained in:
parent
9b835e1003
commit
2a7280ac48
|
@ -15,7 +15,7 @@ import { CANCELLED_STATUS } from "discourse/lib/autocomplete";
|
|||
const CATEGORY_SLUG_REGEXP = /(\#[a-zA-Z0-9\-:]*)$/gi;
|
||||
const USERNAME_REGEXP = /(\@[a-zA-Z0-9\-\_]*)$/gi;
|
||||
const SUGGESTIONS_REGEXP = /(in:|status:|order:|:)([a-zA-Z]*)$/gi;
|
||||
export const TOPIC_REPLACE_REGEXP = /\stopic:\d+/i;
|
||||
export const TOPIC_REPLACE_REGEXP = /\btopic:\d+\s?/i;
|
||||
export const MODIFIER_REGEXP = /.*(\#|\@|:).*$/gi;
|
||||
export const DEFAULT_TYPE_FILTER = "exclude_topics";
|
||||
|
||||
|
@ -385,10 +385,14 @@ export default createWidget("search-menu", {
|
|||
const highlightTerm = searchData.term.replace(TOPIC_REPLACE_REGEXP, "");
|
||||
this.searchService().set("highlightTerm", highlightTerm);
|
||||
}
|
||||
searchData.loading = SearchHelper.includesTopics() ? true : false;
|
||||
|
||||
const delay = SearchHelper.includesTopics() ? 400 : 200;
|
||||
discourseDebounce(SearchHelper, SearchHelper.perform, this, delay);
|
||||
if (SearchHelper.includesTopics()) {
|
||||
searchData.loading = true;
|
||||
SearchHelper.perform(this);
|
||||
} else {
|
||||
searchData.loading = false;
|
||||
discourseDebounce(SearchHelper, SearchHelper.perform, this, 400);
|
||||
}
|
||||
},
|
||||
|
||||
moreOfType(type) {
|
||||
|
|
|
@ -197,6 +197,17 @@ acceptance("Search - Anonymous", function (needs) {
|
|||
"highlights the post correctly"
|
||||
);
|
||||
|
||||
await fillIn("#search-term", "topic:280 interface");
|
||||
await focus("input#search-term");
|
||||
await triggerKeyEvent(".search-menu", "keydown", 40);
|
||||
await click(document.activeElement);
|
||||
|
||||
assert.equal(
|
||||
query("#post_7 span.highlighted").textContent.trim(),
|
||||
"interface",
|
||||
"highlights the post when term is after modifier"
|
||||
);
|
||||
|
||||
await click(".clear-search");
|
||||
assert.equal(query("#search-term").value, "", "clear button works");
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue