Skip to content

Commit

Permalink
controlled vis fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Stephane Comeau committed Apr 9, 2024
1 parent 03aed95 commit 33082b4
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions packages/web-components/fast-foundation/src/tooltip/tooltip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,6 @@ export class FASTTooltip extends FASTElement {
*/
protected documentMouseMoveHandler = (): void => {
// focus generated tooltips are hidden when mouse moves
console.debug("mouse");
if (!this.isHovered) {
this.hideTooltip();
}
Expand All @@ -156,7 +155,6 @@ export class FASTTooltip extends FASTElement {
* @internal
*/
protected documentFocusoutHandler = (): void => {
console.debug("focusout");
// hover generated tooltips are hidden when focus moves
if (getRootActiveElement(this) !== this.anchorElement) {
this.hideTooltip();
Expand Down Expand Up @@ -468,9 +466,11 @@ export class FASTTooltip extends FASTElement {
private showTooltip(): void {
if (!this._visible) {
this._visible = true;
document.addEventListener("mousemove", this.documentMouseMoveHandler);
document.addEventListener("focusout", this.documentFocusoutHandler);
document.addEventListener("keydown", this.keydownDocumentHandler);
if (!this.controlledVisibility) {
document.addEventListener("mousemove", this.documentMouseMoveHandler);
document.addEventListener("focusout", this.documentFocusoutHandler);
document.addEventListener("keydown", this.keydownDocumentHandler);
}
Updates.enqueue(() => this.setPositioning());
}
}
Expand All @@ -482,9 +482,11 @@ export class FASTTooltip extends FASTElement {
*/
public hideTooltip(): void {
if (this._visible) {
document.removeEventListener("mousemove", this.documentMouseMoveHandler);
document.removeEventListener("focusin", this.documentFocusoutHandler);
document.removeEventListener("keydown", this.keydownDocumentHandler);
if (!this.controlledVisibility) {
document.removeEventListener("mousemove", this.documentMouseMoveHandler);
document.removeEventListener("focusin", this.documentFocusoutHandler);
document.removeEventListener("keydown", this.keydownDocumentHandler);
}
this._visible = false;
this.cleanup?.();
}
Expand Down

0 comments on commit 33082b4

Please sign in to comment.