I want to find out wether my HTML Event is on focus (not if it is clicked but focused by navigating with the keyboard).
myElement === document.activeElement
is only true when the element is clicked but not when it's focused by keyboard navigation.
tooltip(){
var myElement = document.getElementById("myID");
let myEvent = "";
if (myElement=== document.activeElement){
myEvent = "focus";
}
return myEvent;
};
<th id="myID" *ngSwitchCase="'validation'" tooltipEvent={{tooltip()}} pTooltip="I am a tooltip"
tooltipPosition="top" [escape]="false" [pSortableColumn]="column.field" [ngStyle]="column.style">
<div class="col-title">
<span data-testid="column-validationl-header" class="ui-column-title" >Validation </span>
<p-sortIcon [field]="column.field" *ngIf="column.sortable"></p-sortIcon>
</div>
</th>
any Ideas?