Skip to content

[tooltip][preview-card] Small cleanups and comment fixes#5039

Open
atomiks wants to merge 1 commit into
mui:masterfrom
atomiks:chore/tooltip-preview-card-cleanups
Open

[tooltip][preview-card] Small cleanups and comment fixes#5039
atomiks wants to merge 1 commit into
mui:masterfrom
atomiks:chore/tooltip-preview-card-cleanups

Conversation

@atomiks

@atomiks atomiks commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Low-risk, behavior-preserving cleanups in Tooltip and Preview Card.

Changes

  • Memoize the per-trigger safePolygon() instance (it captures a Timeout, so it must be per-instance, not shared) instead of allocating one per render.
  • Collapse TooltipProvider's two useMemos into one; tighten previousInstantTypeRef's type; flatten nested if (open) blocks in both roots.
  • Move/correct a few comments (the TooltipRoot instant-animation rationale, the Preview Card reposition-on-open effect) and fix the PreviewCardPopup test's copy-pasted describe title.

Verification

pnpm typescript, pnpm eslint, jsdom Tooltip / PreviewCard all green.

- Memoize the per-trigger `safePolygon()` instance (it captures a timer, so it
  must not be shared) instead of allocating one per render.
- Collapse TooltipProvider's two memos into one; tighten previousInstantTypeRef's
  type; flatten nested `if (open)` blocks.
- Move/correct several comments (TooltipRoot instant-animation rationale, the
  PreviewCard reposition-on-open effect) and fix the PreviewCardPopup test title.
@atomiks atomiks added component: tooltip Changes related to the tooltip component. component: preview card Changes related to the preview card component. labels Jun 12, 2026
@code-infra-dashboard

code-infra-dashboard Bot commented Jun 12, 2026

Copy link
Copy Markdown

Bundle size

Bundle Parsed size Gzip size
@base-ui/react 🔺+63B(+0.01%) 🔺+24B(+0.02%)

Details of bundle changes

Performance

Total duration: 1,277.17 ms -177.08 ms(-12.2%) | Renders: 50 (+0) | Paint: 1,917.67 ms -266.72 ms(-12.2%)

Test Duration Renders
Checkbox mount (500 instances) 66.82 ms ▼-47.27 ms(-41.4%) 1 (+0)

11 tests within noise — details


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

@netlify

netlify Bot commented Jun 12, 2026

Copy link
Copy Markdown

Deploy Preview for base-ui ready!

Name Link
🔨 Latest commit 206f21c
🔍 Latest deploy log https://app.netlify.com/projects/base-ui/deploys/6a2bc0f6279b5e0008ddde3d
😎 Deploy Preview https://deploy-preview-5039--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 requested a review from Copilot June 12, 2026 08:23
@atomiks atomiks marked this pull request as ready for review June 12, 2026 08:23

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR makes small, behavior-preserving cleanups across Tooltip and Preview Card, primarily reducing per-render allocations and improving clarity in code comments/tests.

Changes:

  • Memoizes safePolygon() per trigger instance in Tooltip/Preview Card triggers to avoid allocating a new close-handler on every render.
  • Simplifies Tooltip provider memoization and tightens previousInstantTypeRef typing; flattens redundant nested conditionals in Tooltip/Preview Card roots.
  • Fixes/moves clarifying comments and corrects the PreviewCardPopup test suite title.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.

Show a summary per file
File Description
packages/react/src/tooltip/trigger/TooltipTrigger.tsx Keeps a stable per-trigger safePolygon() close handler instead of recreating it per render.
packages/react/src/tooltip/root/TooltipRoot.tsx Ref typing tightened and small control-flow simplification; comment moved for clarity.
packages/react/src/tooltip/provider/TooltipProvider.tsx Collapses two useMemos into one while preserving memoization behavior.
packages/react/src/preview-card/trigger/PreviewCardTrigger.tsx Keeps a stable per-trigger safePolygon() close handler instead of recreating it per render.
packages/react/src/preview-card/root/PreviewCardRoot.tsx Flattens nested if block when clearing payload on open without an active trigger.
packages/react/src/preview-card/positioner/PreviewCardPositioner.tsx Clarifies the rationale for re-running positioning after open via comment.
packages/react/src/preview-card/popup/PreviewCardPopup.test.tsx Fixes the describe label to match PreviewCard.Popup.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component: preview card Changes related to the preview card component. component: tooltip Changes related to the tooltip component.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants