From e741949c389d808b6be541d900e4c9f441af9892 Mon Sep 17 00:00:00 2001 From: Robson Alves Date: Thu, 28 Nov 2024 15:32:10 -0300 Subject: [PATCH] Enhance highlight directive to blur on keypress for improved accessibility --- src/app/directives/highlight.directive.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/app/directives/highlight.directive.ts b/src/app/directives/highlight.directive.ts index 71b1b03..4906bc4 100644 --- a/src/app/directives/highlight.directive.ts +++ b/src/app/directives/highlight.directive.ts @@ -15,10 +15,10 @@ export class HighlightDirective { private highlight(color: string, visibility: boolean = true) { if (visibility) { this.el.nativeElement.classList.add(color); - this.el.nativeElement.blur(); + this.el.nativeElement.addEventListener('keypress', () => { this.el.nativeElement.blur(); window.focus(); }); } else { this.el.nativeElement.classList.remove(color); - this.el.nativeElement.blur(); + this.el.nativeElement.addEventListener('keypress', () => { this.el.nativeElement.blur(); window.focus(); }); } } }