I have 3 element. when the user focusout
on the last element, I am redirecting back to first element instead of focusing on browser elements. but it's not working. I am not able to prevent the foucusout
how to handle this? How to stop before focusout
and redirect to another method.
here is the snippet of my code :
@HostListener('document:focusout', ['$event']) public DocFocus($event) {
$event.preventDefault();//not works
if (this.lastFocusElement && this.lastFocusElement === $event.target) {
this.setFocus();//got to fist element
console.log('done', this.firstFocusElement);
}
}
on focusout
, now my tab going to browser address bar.