FIX: stop highlighting single l which is used for sorting

This commit is contained in:
Sam 2017-07-03 15:45:15 -04:00
parent 845170bd6b
commit 45c3ad5f91
3 changed files with 12 additions and 2 deletions

View File

@ -46,6 +46,14 @@ export default Ember.Controller.extend({
return Em.isEmpty(q);
},
@computed('q')
highlightQuery(q) {
if (!q) { return; }
// remove l which can be used for sorting
return _.reject(q.split(/\s+/), t => t === 'l').join(' ');
},
@computed('skip_context', 'context')
searchContextEnabled: {
get(skip,context){

View File

@ -107,7 +107,7 @@
</span>
{{#if result.blurb}}
{{#highlight-text highlight=q}}
{{#highlight-text highlight=highlightQuery}}
{{{unbound result.blurb}}}
{{/highlight-text}}
{{/if}}

View File

@ -13,7 +13,9 @@ class Highlighted extends RawHtml {
decorate($html) {
if (this.term) {
$html.highlight(this.term.split(/\s+/), { className: 'search-highlight' });
// special case ignore "l" which is used for magic sorting
const words = _.reject(this.term.split(/\s+/), t => t === 'l');
$html.highlight(words, { className: 'search-highlight' });
}
}
}