From f73aa18a006dbef8d3235ebe1d36eb4236a60d22 Mon Sep 17 00:00:00 2001 From: Henriette Darge Date: Fri, 17 Jun 2022 14:46:34 +0200 Subject: [PATCH] Avoid too often replacement of highlighted strings --- .../app/shared/directives/search-highlight.directive.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/frontend/src/app/shared/directives/search-highlight.directive.ts b/frontend/src/app/shared/directives/search-highlight.directive.ts index f09cf82431..9ff6204d52 100644 --- a/frontend/src/app/shared/directives/search-highlight.directive.ts +++ b/frontend/src/app/shared/directives/search-highlight.directive.ts @@ -15,8 +15,13 @@ export class OpSearchHighlightDirective implements AfterViewChecked { ngAfterViewChecked():void { let el = this.elementRef.nativeElement as HTMLElement; - el = this.cleanUpOldHighlighting(el); + const highlightedElement = el.querySelector('.op-search-highlight'); + if (!!highlightedElement && highlightedElement.innerHTML.toLocaleLowerCase() === this.query) { + return; + } + + el = this.cleanUpOldHighlighting(el); if (!this.query) { return; }