Tooltip closeDelay: 0 should also reset warmup state immediately
- Dominant language
- TypeScript
- Stars
- 15.9k
- Forks
- 1.6k
- Avg merge
- 3d 9m
- Merged PRs (30d)
- 59
Description
### Provide a general summary of the issue here
When closeDelay is explicitly set to 0, the tooltip closes immediately as expected. However, the global warmup state (`globalWarmedUp`) still persists for 500ms due to the hardcoded `TOOLTIP_COOLDOWN` value. This causes subsequent hovers to open the tooltip immediately, ignoring the delay setting.
### 🤔 Expected Behavior?
When closeDelay: 0 is set:
- Tooltip should close immediately(works correctly)
- Warmup state should reset immediately, so the next hover respects the delay setting
https://github.com/user-attachments/assets/95e44860-ee48-4170-89f1-0cd34e8d107e
### 😯 Current Behavior
When closeDelay: 0 is set:
- Tooltip closes immediately
- Warmup state persists for 500ms due to `Math.max(TOOLTIP_COOLDOWN, closeDelay)`
- During this 500ms window, hovering again opens the tooltip immediately, ignoring the delay
https://github.com/user-attachments/assets/bb12fb41-47f0-4230-bdd1-7c3ff7341cba
### 💁 Possible Solution
```ts
// Current code
globalCooldownTimeout = setTimeout(() => {
globalWarmedUp = false;
}, Math.max(TOOLTIP_COOLDOWN, closeDelay));
// Proposed change: Option1 - Special case for `closeDelay: 0`
globalCooldownTimeout = setTimeout(() => {
globalWarmedUp = false;
}, closeDelay === 0 ? 0 : Math.max(TOOLTIP_COOLDOWN, closeDelay));
// Proposed change: Option2 - Simply use closeDelay directly (removes minimum 500ms constraint)
// Option 2 respects the user's explicit closeDelay setting for cooldown as well.
globalCooldownTimeout = setTimeout(() => {
globalWarmedUp = false;
}, closeDelay);
```
### 🔦 Context
_No response_
### 🖥️ Steps to Reproduce
1. Set `delay: 2000` and `closeDelay: 0` on a TooltipTrigger
2. Hover on the trigger and wait for the tooltip to appear (2000ms)
3. Move mouse away - tooltip closes immediately
4. Quickly hover again (within 500ms)
5. Actual: Tooltip opens immediately
6. Expected: Tooltip should wait 2000ms again
### Version
react-stately/tooltip@3.5.9
### What browsers are you seeing the problem on?
Chrome
### If other, please specify.
_No response_
### What operating system are you using?
macOS Tahoe 26.0.1
### 🧢 Your Company/Team
_No response_
### 🕷 Tracking Issue
This issue affects HeroUI tooltip implementation.
Related: https://github.com/heroui-inc/heroui/issues/6122
Contributor guide
Assessment
This issue has not been assessed yet.