Skip to content

fix(Tooltip): skip delay race condition with multiple tooltips#2002

Merged
huntabyte merged 3 commits intohuntabyte:mainfrom
AndersRobstad:fix/tooltip-skip-delay-race
Mar 30, 2026
Merged

fix(Tooltip): skip delay race condition with multiple tooltips#2002
huntabyte merged 3 commits intohuntabyte:mainfrom
AndersRobstad:fix/tooltip-skip-delay-race

Conversation

@AndersRobstad
Copy link
Copy Markdown
Contributor

@AndersRobstad AndersRobstad commented Mar 27, 2026

Summary

  • Fixes a race condition where the skip-delay timer was unconditionally started when any tooltip closed, including force-closes triggered by another tooltip opening under the same provider
  • After the timer expired (~300ms), isOpenDelayed reset to true, causing subsequent tooltip switches to require the full delayDuration again instead of opening instantly
  • Moves #startTimer() inside the #openTooltip === tooltip guard so it only fires on genuine user-initiated closes

Closes #2001

With the new implementation:

Skjermopptak.2026-03-27.kl.12.39.40.mov

With the old one:

Skjermopptak.2026-03-27.kl.12.40.37.mov

When multiple tooltips share a provider, force-closing one tooltip to
open another would unconditionally start the skip-delay timer. After
the timer expired (default 300ms), `isOpenDelayed` reset to `true`,
causing subsequent tooltip switches to require the full delay again.

Move `#startTimer()` inside the `#openTooltip === tooltip` guard so
the skip-delay timer only starts on genuine closes — not when a
tooltip is force-closed because another one opened.

Closes huntabyte#2001

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Mar 27, 2026

🦋 Changeset detected

Latest commit: 0a66305

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
bits-ui Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 27, 2026

built with Refined Cloudflare Pages Action

⚡ Cloudflare Pages Deployment

Name Status Preview Last Commit
bits-ui ✅ Ready (View Log) Visit Preview 0a66305

@huntabyte
Copy link
Copy Markdown
Owner

@AndersRobstad thanks a ton for this. Would you mind adding a test to the tooltip.browser.test.ts file that fails without this fix but passes with this fix? This will ensure we protect from regressions later on.

If you don't have the cycles to add the test I can add it once I have some time soon!

@huntabyte
Copy link
Copy Markdown
Owner

Went ahead and added the tests as I had some time on my hand, thanks a ton! @AndersRobstad

@AndersRobstad
Copy link
Copy Markdown
Contributor Author

Went ahead and added the tests as I had some time on my hand, thanks a ton! @AndersRobstad

Ahhh thanks, great! Forgot to do that when I fixed it, looks great @huntabyte 💯

@huntabyte huntabyte merged commit 14cb4eb into huntabyte:main Mar 30, 2026
7 of 8 checks passed
@github-actions github-actions bot mentioned this pull request Mar 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: Tooltips don't always skip skipDelayDuration when inside same provider

2 participants