From d95e0a59415c29b10dfd59dd41cf0439f6f9a007 Mon Sep 17 00:00:00 2001 From: Saylee12R Date: Sat, 20 Jun 2026 12:48:14 +0530 Subject: [PATCH] fix: prevent onboarding tooltip from going off-screen --- src/components/OnboardingTour.tsx | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/src/components/OnboardingTour.tsx b/src/components/OnboardingTour.tsx index c1cef066..428271a7 100644 --- a/src/components/OnboardingTour.tsx +++ b/src/components/OnboardingTour.tsx @@ -76,16 +76,20 @@ function getTooltipStyle( top: sr.top - th - TOOLTIP_OFFSET, left: sr.left + sr.width / 2 - tw / 2, }; - case "left": - return { - top: sr.top + sr.height / 2 - th / 2, - left: sr.left - tw - TOOLTIP_OFFSET, - }; - case "right": - return { - top: sr.top + sr.height / 2 - th / 2, - left: sr.left + sr.width + TOOLTIP_OFFSET, - }; + case "left": + return { + top: Math.max(16, sr.top + sr.height / 2 - th / 2), + left: Math.max(16, sr.left - tw - TOOLTIP_OFFSET), + }; + +case "right": + return { + top: Math.max(16, sr.top + sr.height / 2 - th / 2), + left: Math.min( + window.innerWidth - tw - 16, + sr.left + sr.width + TOOLTIP_OFFSET, + ), + }; case "bottom": default: return { @@ -178,8 +182,7 @@ function Tooltip({ className="fixed z-[9999] w-80 rounded-xl shadow-2xl border bg-[var(--surface)] border-[var(--border)] - text-[var(--text)] - transition-all duration-200" + text-[var(--text)]" style={{ ...style }} tabIndex={-1} >