Skip to content

Commit

Permalink
Keep popover alive when mouse enters the user card (#154)
Browse files Browse the repository at this point in the history
  • Loading branch information
gaogaotiantian authored Jun 28, 2024
1 parent 430704d commit 66a9a09
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions scripts/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -411,17 +411,33 @@ UserProfileCard.prototype.updateTarget = function(target) {
UserProfileCard.prototype.setLeaveEvent = function() {
let validTargets = [this.el, this.target];

// The UI lives directly under document so switching to the UI will trigger
// the leave event. We need to dispatch the event to the popover to prevent
// the popover from disappearing.
const dispatchToPopover = (event) => {
let node = this.target;
while (node && node != document) {
if (node.classList && node.classList.contains("v-popover")) {
node.dispatchEvent(new Event(event));
break;
}
node = node.parentNode;
}
}

this.leaveCallback = () => {
if (this.disable()) {
for (let target of validTargets) {
target.removeEventListener("mouseleave", this.disableDebounce);
target.removeEventListener("mouseenter", this.enterCallback);
}
dispatchToPopover("mouseleave");
}
}

this.enterCallback = () => {
clearTimeout(this.disableDebounce.timer);
dispatchToPopover("mouseenter");
this.cursorInside = true;
}

Expand Down

0 comments on commit 66a9a09

Please sign in to comment.