Skip to content

Instantly share code, notes, and snippets.

View ElenaG518's full-sized avatar

ElenaG518 ElenaG518

View GitHub Profile
@AlejandroPerezMartin
AlejandroPerezMartin / button-focus-remover.ts
Last active April 11, 2023 15:18
Angular 9+ Directive to remove focus after clicking the specified selector/s
import { Directive, HostListener, ElementRef } from '@angular/core';
/**
* This directive removes focus from the selectors after clicking on them
*/
@Directive({
selector: 'button, a' // your selectors here!
})
export class FocusRemover {
constructor(private elRef: ElementRef) {}