Skip to content

Conversation

RickeyWard
Copy link

@RickeyWard RickeyWard commented Aug 30, 2025

Changing --rt-transition-show-delay anywhere except in head or on body were not be picked up by show/hide timeouts causing out animations to be skipped entirely by removing the tooltip from the DOM when not using default positioned styles. This change evaluates the variable on the tooltip its self so that the property can be honored lower in the tree, which is already is for the animations, just not for the js timers.

Motivation: Using in a project intended to be embedded in other GUIs that should not modify the the DOM outside of its parent. I can't find a compelling reason why this computed style needs to be pinned to the document.body scope.

note: Either the naming of these variables are confusing or its possibly just using the wrong css variable here, --rt-transition-show-delay is used to delay unmounting when hiding and also to control the length of the default fade-in animation. It appears that this should really use --rt-transition-closing-delay as that's what dictates the length of the fade out duration. being new to the codebase I didn't want to make any assumptions but I'd be happy to change this as part of this PR if desired.

Summary by CodeRabbit

  • Bug Fixes
    • Tooltip animations now respect each tooltip’s own transition delay settings, ensuring consistent and predictable show/hide timing.
    • Resolves cases where custom theme or per-tooltip CSS variables were ignored, which could cause unexpected delays.
    • Improves visual consistency across different tooltips without changing overall behavior.

Changing `--rt-transition-show-delay` anywhere except in head or on body were not be picked up by show/hide timeouts causing out animations to be skipped entirely by removing the tooltip from the DOM. this change evaluates the variable on the tooltip its self so that the property can be honored lower in the tree.
Copy link

coderabbitai bot commented Aug 30, 2025

Walkthrough

The tooltip component now computes the transition delay from the tooltip’s own DOM node (via tooltipRef) instead of always using document.body, with a fallback to document.body. No exports or public APIs changed.

Changes

Cohort / File(s) Summary
Tooltip transition delay source update
src/components/Tooltip/Tooltip.tsx
Compute CSS transition delay using tooltipRef.current when available; fallback to document.body. No other logic or API changes.

Sequence Diagram(s)

sequenceDiagram
    autonumber
    actor User
    participant Trigger as TooltipTrigger
    participant Tooltip as Tooltip Component
    participant DOM as DOM/CSS

    User->>Trigger: Hover/Focus
    Trigger->>Tooltip: Show tooltip
    Tooltip->>DOM: Render tooltip element

    rect rgba(173,216,230,0.25)
    Note over Tooltip: Determine transition delay
    Tooltip->>Tooltip: Has tooltipRef.current?
    alt Ref available
        Tooltip->>DOM: getComputedStyle(tooltipRef.current)["--rt-transition-show-delay"]
    else Fallback
        Tooltip->>DOM: getComputedStyle(document.body)["--rt-transition-show-delay"]
    end
    end

    Tooltip->>DOM: Apply delay to hide transition
    User-->>Trigger: Unhover/Blur
    Trigger->>Tooltip: Hide tooltip (with computed delay)
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

I nudge a hint of time, just so—
From my tooltip burrow, watch it flow.
Ref-first hops, body as a trail,
Delays aligned, no twitchy tail.
Thump-thump! The UI feels just right—
A rabbit’s tweak, a smoother night. 🐇✨

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore or @coderabbit ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (2)
src/components/Tooltip/Tooltip.tsx (2)

239-251: Optional: prefer nullish coalescing and support a dedicated closing var

Minor polish and future-proofing:

  • Use ?? over || for clarity with nullable refs.
  • If you later introduce --rt-transition-closing-delay, honor it first while keeping full backward compatibility.

Apply this diff:

-      const style = getComputedStyle(tooltipRef.current || document.body)
-      const transitionShowDelay = cssTimeToMs(style.getPropertyValue('--rt-transition-show-delay'))
+      const el = tooltipRef.current ?? document.body
+      const style = getComputedStyle(el)
+      const closingVar =
+        style.getPropertyValue('--rt-transition-closing-delay').trim() ||
+        style.getPropertyValue('--rt-transition-show-delay')
+      const transitionShowDelay = cssTimeToMs(closingVar)

239-251: Test suggestion: assert element-scoped var affects unmount timing

Add a test that sets --rt-transition-show-delay on the tooltip node (not body) and asserts the hide fallback waits that duration before unmounting (e.g., via fake timers and onTransitionEnd not firing). I can sketch the test if helpful.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 9faf2c6 and e18f956.

📒 Files selected for processing (1)
  • src/components/Tooltip/Tooltip.tsx (1 hunks)
🔇 Additional comments (1)
src/components/Tooltip/Tooltip.tsx (1)

239-241: Compute CSS var from the tooltip element — LGTM

Reading the custom property from tooltipRef.current (with a safe fallback) fixes the scoping bug described in the PR and aligns JS timers with CSS animations.

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.

1 participant