Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(v4 tooltip): tooltip arrow overlap issue #6934

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

paaskus
Copy link

@paaskus paaskus commented Mar 15, 2025

Issue

This PR addresses the issue described in #6933 where the tooltip arrow can overlap with and appear above the tooltip content, potentially obscuring parts of the text or other tooltip content. Applies to the latest <Tooltip> component based on Tailwind v4 and React 19 with the new-york style.

Problem

The tooltip arrow is implemented as a rotated square with styling that positions it in a way that can cause it to overlap with the tooltip content. Additionally, the z-index configuration allows the arrow to appear above the content, which can hide parts of the text when they overlap.

Solution

This PR simplifies the arrow implementation by:

  • Removing custom styling properties that were causing positioning issues
  • Letting the default Radix UI tooltip arrow behavior handle the positioning
  • Ensuring proper layering so the arrow doesn't obscure the content

See this CodeSandbox for a demo of the problem and the proposed solution: https://codesandbox.io/p/devbox/shadcn-tooltip-arrow-issue-8xdqwl

Changes

  • Modified the TooltipContent component to use a more appropriate sideOffset value to compensate for the removed styles (achieving the same rendered UI)
  • Simplified the arrow styling to prevent overlap issues
  • Maintained the original design intent while fixing the functional issue

Screenshots

  1. Before: The tooltip with the arrow overlapping content
  2. After: The tooltip with the arrow properly positioned without overlap
tooltip-arrow-issue

Related

Fixes #6933

paaskus added 2 commits March 15, 2025 01:10
Updated the default sideOffset value from 0 to 5 for better positioning. Simplified the TooltipArrow class by removing unnecessary styles, enhancing maintainability.
Copy link

vercel bot commented Mar 15, 2025

@paaskus is attempting to deploy a commit to the shadcn-pro Team on Vercel.

A member of the Team first needs to authorize it.

Copy link

vercel bot commented Mar 16, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
ui ✅ Ready (Inspect) Visit Preview Mar 16, 2025 9:14am
v4 ✅ Ready (Inspect) Visit Preview Mar 16, 2025 9:14am

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]: [v4] Tooltip Arrow Overlaps Tooltip Content
1 participant