Skip to content

[tooltip] Reset preventUnmountOnClose on reopen#4885

Open
michaldudak wants to merge 2 commits into
mui:masterfrom
michaldudak:codex/tooltip-prevent-unmount-reset
Open

[tooltip] Reset preventUnmountOnClose on reopen#4885
michaldudak wants to merge 2 commits into
mui:masterfrom
michaldudak:codex/tooltip-prevent-unmount-reset

Conversation

@michaldudak
Copy link
Copy Markdown
Member

@michaldudak michaldudak commented May 22, 2026

Summary

  • Reset the tooltip store's prevented-unmount flag when the popup opens again.
  • Prevent one preventUnmountOnClose() close from making later closes stay mounted forever.
  • Add regression coverage for a prevented close followed by a normal close.

Bug

Calling preventUnmountOnClose() latches preventUnmountingOnClose permanently. After one prevented close, later normal closes can keep the tooltip positioner mounted forever instead of unmounting after close completion.

Reproduction

Test plan

  • pnpm test:jsdom TooltipRoot --no-watch
  • pnpm test:chromium TooltipRoot --no-watch

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented May 22, 2026

commit: 00e1c8f

@code-infra-dashboard
Copy link
Copy Markdown

code-infra-dashboard Bot commented May 22, 2026

Bundle size

Bundle Parsed size Gzip size
@base-ui/react 🔺+106B(+0.02%) 🔺+27B(+0.02%)

Details of bundle changes

Performance

Total duration: 1,259.24 ms -132.41 ms(-9.5%) | Renders: 50 (+0) | Paint: 1,929.59 ms -199.47 ms(-9.4%)

Test Duration Renders
Tooltip mount (300 contained roots) 45.94 ms ▼-16.25 ms(-26.1%) 1 (+0)

11 tests within noise — details


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

@netlify
Copy link
Copy Markdown

netlify Bot commented May 22, 2026

Deploy Preview for base-ui ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 00e1c8f
🔍 Latest deploy log https://app.netlify.com/projects/base-ui/deploys/6a102960e622510008a38aed
😎 Deploy Preview https://deploy-preview-4885--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.

@michaldudak michaldudak added type: bug It doesn't behave as expected. component: tooltip Changes related to the tooltip component. labels May 22, 2026
Copy link
Copy Markdown
Member Author

Codex Review (GPT-5.5)

Reviewed the full PR diff for #4885 against freshly fetched upstream/master. Dominant type: bug-fix; the patch is narrow and targets the latched preventUnmountOnClose() state after a prevented tooltip close.

1. Bugs / Issues (None)

I did not find any concrete branch-relevant bugs or regressions in the implementation.

Root Cause & Patch Assessment

The fix resets preventUnmountingOnClose only on a closed-to-open transition, which preserves the current prevented close while preventing the flag from leaking into later close cycles. Keeping the reset inside useOpenStateTransitions also makes the shared popup lifecycle behavior consistent for the other popup primitives that use the same utility.

Repo Conventions / Cleanliness Assessment

The change follows the repo’s hook utility guidance by using useIsoLayoutEffect, and the dependency list is explicit. No public API, docs-generated types, or error messages were changed.

Test Coverage Assessment

I ran pnpm test:jsdom TooltipRoot --no-watch, pnpm test:chromium TooltipRoot --no-watch, pnpm eslint, and git diff --check; all passed. The new regression test runs through the existing contained, detached, and multiple-detached tooltip variants, which is good coverage for the changed lifecycle path. I did not separately transplant the new test onto upstream/master to prove the red/green failure at base.

Recommendation

Approve ✅

The patch addresses the root cause cleanly, the regression coverage matches the reported failure, and the targeted validation passed.

@michaldudak michaldudak marked this pull request as ready for review May 22, 2026 11:29
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