Skip to content

[tooltip] Respect trigger delay with zero provider delay - #5444

Merged
atomiks merged 2 commits into
mui:masterfrom
atomiks:codex/fix-tooltip-trigger-delay
Aug 10, 2026
Merged

atomiks merged 2 commits into
mui:masterfrom
atomiks:codex/fix-tooltip-trigger-delay

Conversation

@atomiks

@atomiks atomiks commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

shadcn/ui sets <Tooltip.Provider delay={0}> by default. In that configuration, a non-zero <Tooltip.Trigger delay> was ignored because the provider's configured zero delay was indistinguishable from the delay group's temporary instant phase.

Changes

  • Use the group's existing active tooltip ID to decide when opening should be instant, allowing the trigger delay to override the provider delay before the group becomes active.
  • Preserve instant adjacent tooltip opens while the group is active and restore the trigger delay after the timeout.
  • Add regression coverage for the zero provider delay and per-trigger delay combination.

Related: shadcn-ui/ui#9617

@atomiks atomiks added type: bug It doesn't behave as expected. component: tooltip Changes related to the tooltip component. labels Aug 10, 2026
@pkg-pr-new

pkg-pr-new Bot commented Aug 10, 2026 •

Copy link
Copy Markdown
  • base-ui-tanstack-start

  • vite-css-base-ui-example

    pnpm add https://pkg.pr.new/mui/base-ui/@base-ui/react@5444
    
    pnpm add https://pkg.pr.new/mui/base-ui/@base-ui/utils@5444
    

commit: b6243e1

@code-infra-dashboard

code-infra-dashboard Bot commented Aug 10, 2026 •

Copy link
Copy Markdown

Bundle size

Bundle Parsed size Gzip size
@base-ui/react 🔺+11B(0.00%) 🔺+7B(0.00%)

Details of bundle changes

Performance

Total duration: 1,209.77 ms +117.81 ms(+10.8%) | Renders: 76 (+0) | Paint: 1,912.49 ms +188.61 ms(+10.9%)

Test Duration Renders
Menu mount (300 instances) 114.84 ms 🔺+29.47 ms(+34.5%) 1 (+0)
Scroll Area mount (300 instances) 90.48 ms 🔺+18.25 ms(+25.3%) 3 (+0)
Mixed surface mount (app-like density) 75.97 ms 🔺+15.62 ms(+25.9%) 5 (+0)
Combobox open — 500 items 47.29 ms 🔺+11.93 ms(+33.7%) 4 (+0)
Combobox type — 500 items, all stay mounted (type "Row ") 38.35 ms 🔺+6.48 ms(+20.3%) 11 (+0)

…and 1 more (+9 within noise) — details

Metric alarms

Test Metric Change
Menu mount (300 instances) bench:paint 🔺 +41.80 ms
Scroll Area mount (300 instances) bench:paint 🔺 +17.83 ms
Mixed surface mount (app-like density) bench:paint 🔺 +26.94 ms
Combobox open — 500 items bench:paint#combobox-open 🔺 +20.99 ms
Combobox open — 500 items bench:paint 🔺 +20.99 ms

…and 2 more metric alarms — details


Check out the code infra dashboard for more information about this PR.

@netlify

netlify Bot commented Aug 10, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for base-ui ready!

Name Link
🔨 Latest commit b6243e1
🔍 Latest deploy log https://app.netlify.com/projects/base-ui/deploys/6a7951bd0ff9840008542a28
😎 Deploy Preview https://deploy-preview-5444--base-ui.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@atomiks

atomiks commented Aug 10, 2026

Copy link
Copy Markdown
Contributor Author

@claude review low

@github-actions

github-actions Bot commented Aug 10, 2026 •

Copy link
Copy Markdown

PR review

No findings.

The swap from the delayRef.current.open === 0 sentinel to the group's currentIdRef holds up: FloatingDelayGroup.tsx mutates both in lockstep — the open effect (packages/react/src/floating-ui-react/components/FloatingDelayGroup.tsx:229-233), unset() (:169-175), the unmount cleanup (:256-270), and the delay-change effect that preserves open: 0 while currentIdRef is set (:83-86) — so the only behavioral divergence is the intended one (provider delay: 0 while the group is inactive). Dropping the if (!hasProvider) early return is also safe, because TooltipProvider.tsx:19-23 always renders TooltipProviderContext.Provider and FloatingDelayGroup together, making providerDelay undefined whenever hasProvider is false, so delay ?? providerDelay ?? OPEN_DELAY collapses to the old delayWithDefault. Nothing here is merge-blocking.

Residual risk worth knowing about:

  • <Tooltip.Provider> with no delay prop is unchanged, since getDelay({ open: undefined }, 'open') returns undefined rather than 0 (packages/react/src/floating-ui-react/hooks/useHoverShared.ts:46-57), so the old branch already fell through to OPEN_DELAY. This is the case most likely to have regressed and it does not.
  • The new check uses activeIdRef.current != null, while the group's own internal checks use falsiness (!currentIdRef.current, FloatingDelayGroup.tsx:78 and :177). These agree for null/undefined and diverge only for an empty-string floatingId, which tooltips cannot produce (it comes from useId), so this is theoretical rather than reachable.
  • Coverage is jsdom fake-timer only. The real-pointer restMs path and the handleNestedTriggerHover reopen path (which also calls getOpenDelay) are not exercised by the new test, though neither changes semantics relative to the old expression.

This was run at low effort, so it is a bugs-only pass: test quality, simplifications, and docs were intentionally not reviewed.

Verdict

Approve - the new group-active check is behaviorally equivalent to the old delay-ref sentinel everywhere except the zero-provider-delay case it is meant to fix.


🤖 Review generated with Claude Code · low effort · 17 turns · 4m42s · $1.13 · run

@atomiks
atomiks marked this pull request as ready for review August 10, 2026 04:37
@atomiks
atomiks merged commit 641f80a into mui:master Aug 10, 2026
6 checks passed
@atomiks
atomiks deleted the codex/fix-tooltip-trigger-delay branch August 11, 2026 03:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component: tooltip Changes related to the tooltip component. type: bug It doesn't behave as expected.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant