Skip to content

Commit

Permalink
code review feedback: rename leftTooltip, use arrow function, add cle…
Browse files Browse the repository at this point in the history
…arTimeout
  • Loading branch information
margaree committed Jan 20, 2025
1 parent 6c5d89d commit 6d1db30
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions components/tooltip/tooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ class Tooltip extends RtlMixin(LitElement) {
this._viewportMargin = defaultViewportMargin;

this.#isHoveringTooltip = false;
this.#leftTooltip = false;
this.#mouseLeftTooltip = false;
}

/** @ignore */
Expand Down Expand Up @@ -649,7 +649,7 @@ class Tooltip extends RtlMixin(LitElement) {
}

#isHoveringTooltip;
#leftTooltip;
#mouseLeftTooltip;

_addListeners() {
if (!this._target) {
Expand Down Expand Up @@ -847,7 +847,7 @@ class Tooltip extends RtlMixin(LitElement) {

_onTargetMouseEnter() {
// came from tooltip so keep showing
if (this.#leftTooltip) {
if (this.#mouseLeftTooltip) {
this._isHovering = true;
return;
}
Expand All @@ -867,7 +867,7 @@ class Tooltip extends RtlMixin(LitElement) {
_onTargetMouseLeave() {
clearTimeout(this._hoverTimeout);
this._isHovering = false;
setTimeout(this._updateShowing.bind(this), 100); // delay to allow for mouseenter to fire if hovering on tooltip
setTimeout(() => this._updateShowing(), 100); // delay to allow for mouseenter to fire if hovering on tooltip
}

_onTargetResize() {
Expand Down Expand Up @@ -1027,10 +1027,13 @@ class Tooltip extends RtlMixin(LitElement) {
}

#onTooltipMouseLeave() {
clearTimeout(this._mouseLeaveTimeout);

this.#isHoveringTooltip = false;
this.#leftTooltip = true;
setTimeout(() => {
this.#leftTooltip = false;
this.#mouseLeftTooltip = true;

this._mouseLeaveTimeout = setTimeout(() => {
this.#mouseLeftTooltip = false;
this._updateShowing();
}, 100); // delay to allow for mouseenter to fire if hovering on target
}
Expand Down

0 comments on commit 6d1db30

Please sign in to comment.