Skip to content

Commit

Permalink
🎭 Add tooltipopen attribute to tooltip opener nodes when a tooltip be…
Browse files Browse the repository at this point in the history
…gins showing
  • Loading branch information
kierandrewett committed Feb 15, 2024
1 parent 7720a4e commit a9be979
Showing 1 changed file with 34 additions and 1 deletion.
35 changes: 34 additions & 1 deletion actors/DotTooltipListenerChild.sys.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -152,13 +152,22 @@ export class DotTooltipListenerChild extends JSWindowActorChild {
Services.els.removeSystemEventListener(doc, "mouseup", this, true);
Services.els.removeSystemEventListener(doc, "keydown", this, true);

Services.els.removeSystemEventListener(
this._currentTooltip,
"popupshowing",
this,
false
);

Services.els.removeSystemEventListener(
this._currentTooltip,
"popuphiding",
this,
false
);

this._currentTriggerNode.removeAttribute("tooltipopen");

this.killTooltipTimer();

this._currentTooltip = null;
Expand Down Expand Up @@ -353,6 +362,13 @@ export class DotTooltipListenerChild extends JSWindowActorChild {
triggerNode || event.target
);

Services.els.addSystemEventListener(
tooltip,
"popupshowing",
this,
false
);

Services.els.addSystemEventListener(
tooltip,
"popuphiding",
Expand Down Expand Up @@ -383,7 +399,7 @@ export class DotTooltipListenerChild extends JSWindowActorChild {
this._currentTriggerNode,
tooltipAnchor,
0,
-kTooltipMouseTopMargin,
0,
false,
false,
event
Expand Down Expand Up @@ -507,6 +523,18 @@ export class DotTooltipListenerChild extends JSWindowActorChild {
}
}

/**
* Fired when the tooltip starts showing
*/
onTooltipShowing() {
if (!this._currentTooltip) return;

this._currentTriggerNode.setAttribute(
"tooltipopen",
this._currentTooltip.id || ""
);
}

/**
* Adds tooltip support to a node
* @param {Node} node
Expand Down Expand Up @@ -549,6 +577,11 @@ export class DotTooltipListenerChild extends JSWindowActorChild {
return;
}

if (event.type == "popupshowing") {
this.onTooltipShowing();
return;
}

if (event.type == "popuphiding") {
this.destroyTooltip();
return;
Expand Down

0 comments on commit a9be979

Please sign in to comment.