Skip to content

Commit

Permalink
fix: do not open popover after mouseleave during hover delay (#8093)
Browse files Browse the repository at this point in the history
  • Loading branch information
web-padawan authored Nov 5, 2024
1 parent 8eb78da commit 15dcade
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/popover/src/vaadin-popover.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ class PopoverOpenedStateController {
this.__abortClose();
this.__setOpened(false);
}

this.__abortOpen();
}

/** @private */
Expand Down Expand Up @@ -786,7 +788,7 @@ class Popover extends PopoverPositionMixin(
__onTargetMouseLeave(event) {
// Do not close the popover on target focusout if the overlay is not the last one.
// This happens e.g. when opening the nested popover that uses non-modal overlay.
if (!isLastOverlay(this._overlayElement)) {
if (this._overlayElement.opened && !isLastOverlay(this._overlayElement)) {
return;
}

Expand Down
11 changes: 11 additions & 0 deletions packages/popover/test/timers.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,17 @@ describe('timers', () => {
await nextUpdate(popover);
expect(overlay.opened).to.be.true;
});

it('should not open the overlay after mouseleave during hover delay', async () => {
mouseenter(target);
await nextUpdate(popover);
expect(overlay.opened).to.be.false;

mouseleave(target);

await aTimeout(5);
expect(overlay.opened).to.be.false;
});
});

describe('focusDelay', () => {
Expand Down

0 comments on commit 15dcade

Please sign in to comment.