diff --git a/packages/tooltip/src/vaadin-tooltip-mixin.js b/packages/tooltip/src/vaadin-tooltip-mixin.js index 546ee2ad0e..0e8a7a8300 100644 --- a/packages/tooltip/src/vaadin-tooltip-mixin.js +++ b/packages/tooltip/src/vaadin-tooltip-mixin.js @@ -51,19 +51,19 @@ class TooltipStateController { /** @private */ get focusDelay() { const tooltip = this.host; - return tooltip.focusDelay != null && tooltip.focusDelay > 0 ? tooltip.focusDelay : defaultFocusDelay; + return tooltip.focusDelay != null && tooltip.focusDelay >= 0 ? tooltip.focusDelay : defaultFocusDelay; } /** @private */ get hoverDelay() { const tooltip = this.host; - return tooltip.hoverDelay != null && tooltip.hoverDelay > 0 ? tooltip.hoverDelay : defaultHoverDelay; + return tooltip.hoverDelay != null && tooltip.hoverDelay >= 0 ? tooltip.hoverDelay : defaultHoverDelay; } /** @private */ get hideDelay() { const tooltip = this.host; - return tooltip.hideDelay != null && tooltip.hideDelay > 0 ? tooltip.hideDelay : defaultHideDelay; + return tooltip.hideDelay != null && tooltip.hideDelay >= 0 ? tooltip.hideDelay : defaultHideDelay; } /** diff --git a/packages/tooltip/test/tooltip-timers.common.js b/packages/tooltip/test/tooltip-timers.common.js index 18436979fd..dda6772428 100644 --- a/packages/tooltip/test/tooltip-timers.common.js +++ b/packages/tooltip/test/tooltip-timers.common.js @@ -56,6 +56,7 @@ describe('timers', () => { afterEach(() => { resetGlobalTooltipState(); + Tooltip.setDefaultHoverDelay(0); }); it('should open the overlay after a delay on mouseenter', async () => { @@ -71,6 +72,14 @@ describe('timers', () => { target.focus(); expect(overlay.opened).to.be.true; }); + + it('should use the hover delay set to 0 and not the global delay', () => { + Tooltip.setDefaultHoverDelay(50); + tooltip.hoverDelay = 0; + + mouseenter(target); + expect(overlay.opened).to.be.true; + }); }); describe('focusDelay', () => { @@ -86,6 +95,7 @@ describe('timers', () => { afterEach(() => { resetGlobalTooltipState(); + Tooltip.setDefaultFocusDelay(0); }); it('should open the overlay after a delay on keyboard focus', async () => { @@ -101,6 +111,15 @@ describe('timers', () => { mouseenter(target); expect(overlay.opened).to.be.true; }); + + it('should use the focus delay set to 0 and not the global delay', () => { + Tooltip.setDefaultFocusDelay(50); + tooltip.focusDelay = 0; + + tabKeyDown(document.body); + target.focus(); + expect(overlay.opened).to.be.true; + }); }); describe('hideDelay', () => { @@ -116,6 +135,7 @@ describe('timers', () => { afterEach(() => { resetGlobalTooltipState(); + Tooltip.setDefaultHideDelay(0); }); it('should close the overlay after a hide delay on mouseleave', async () => { @@ -135,6 +155,15 @@ describe('timers', () => { expect(overlay.opened).to.be.false; }); + it('should use the hide delay set to 0 and not the global delay', () => { + Tooltip.setDefaultHideDelay(50); + tooltip.hideDelay = 0; + + mouseenter(target); + mouseleave(target); + expect(overlay.opened).to.be.false; + }); + it('should close the overlay immediately on mousedown', () => { tabKeyDown(document.body); target.focus();