27.09.2022, 09:14
I want to find out wether my HTML Event is on focus (not if it is clicked but focused by navigating with the keyboard).
is only true when the element is clicked but not when it's focused by keyboard navigation.
any Ideas?
Code:
myElement === document.activeElement
Code:
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>