FIX: Search term scoped to topic should be highlighted in widget dom era.

https://meta.discourse.org/t/highlight-the-search-results/10322/4?u=tgxworld
This commit is contained in:
Guo Xiang Tan 2018-05-07 15:17:34 +08:00
parent ad833c4485
commit 32147d4ff9
3 changed files with 9 additions and 1 deletions

View File

@ -20,7 +20,9 @@ export default class PostCooked {
}
update(prev) {
if (prev.attrs.cooked !== this.attrs.cooked) {
if ((prev.attrs.cooked !== this.attrs.cooked) ||
(prev.attrs.highlightTerm !== this.attrs.highlightTerm)) {
return this.init();
}
}

View File

@ -64,6 +64,7 @@ const SearchHelper = {
}
searchData.results = content;
widget.appEvents.trigger('post-stream:refresh', { force: true });
}).finally(() => {
searchData.loading = false;
widget.scheduleRerender();

View File

@ -69,6 +69,11 @@ QUnit.test("Search with context", assert => {
andThen(() => {
assert.ok(exists('.search-menu .results ul li'), 'it shows results');
assert.ok(
exists('.cooked span.highlight-strong'),
'it should highlight the search term'
);
});
visit("/");