Skip to content

Commit d161887

Browse files
committed
fix(web): timeline minimap preview no longer steals hover or jumps around
1 parent 6577c6b commit d161887

1 file changed

Lines changed: 5 additions & 30 deletions

File tree

‎apps/web/src/components/chat/TimelineMinimap.tsx‎

Lines changed: 5 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,6 @@ import {
1313
import { Tooltip, TooltipPopup, TooltipTrigger } from "../ui/tooltip";
1414
import { cn } from "~/lib/utils";
1515

16-
function timelineMinimapEventTargetsPreview(target: EventTarget): boolean {
17-
return target instanceof Element && target.closest("[data-minimap-preview]") !== null;
18-
}
19-
2016
// A release outside the window can skip `mouseup`, so the next button-free
2117
// `mousemove` also counts.
2218
function onMouseButtonsReleased(onRelease: () => void): () => void {
@@ -72,14 +68,6 @@ export function TimelineMinimap({
7268
resolvedActiveIndex === null
7369
? 0
7470
: resolveTimelineMinimapTopPercent(resolvedActiveIndex, items.length);
75-
const activeTooltipTranslate =
76-
resolvedActiveIndex === null
77-
? "-50%"
78-
: resolvedActiveIndex === 0
79-
? "0%"
80-
: resolvedActiveIndex === items.length - 1
81-
? "-100%"
82-
: "-50%";
8371
const resolvedCurrentIndex =
8472
currentIndex !== null && currentIndex >= 0 && currentIndex < items.length ? currentIndex : null;
8573
const previousItem =
@@ -157,12 +145,9 @@ export function TimelineMinimap({
157145
/>
158146
<button
159147
aria-label={`Jump to message: ${activeItem?.userText ?? "User message"}`}
160-
className="absolute inset-y-0 left-0 w-full cursor-pointer bg-transparent focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring/70"
148+
className="absolute inset-y-0 left-0 w-full cursor-pointer bg-transparent before:absolute before:inset-x-0 before:-inset-y-1 before:content-[''] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring/70"
161149
onBlur={() => setActiveIndex(null)}
162150
onClick={(event) => {
163-
if (timelineMinimapEventTargetsPreview(event.target)) {
164-
return;
165-
}
166151
const nextIndex = resolveActiveIndexFromPointer(event);
167152
const selectedItem = nextIndex === null ? null : (items[nextIndex] ?? null);
168153
if (selectedItem) {
@@ -196,12 +181,7 @@ export function TimelineMinimap({
196181
if (event.buttons !== 0 && !pressedOnStripRef.current) return;
197182
updateActiveIndexFromPointer(event);
198183
}}
199-
onMouseDown={(event) => {
200-
if (timelineMinimapEventTargetsPreview(event.target)) {
201-
return;
202-
}
203-
event.preventDefault();
204-
}}
184+
onMouseDown={(event) => event.preventDefault()}
205185
type="button"
206186
>
207187
<div className="absolute top-0 left-3 h-full w-px bg-border/15" />
@@ -243,13 +223,8 @@ export function TimelineMinimap({
243223
})}
244224
{activeItem ? (
245225
<span
246-
className="pointer-events-auto absolute left-8 w-80 cursor-text select-text"
247-
data-minimap-preview
248-
onMouseMove={(event) => event.stopPropagation()}
249-
style={{
250-
top: `${activeTopPercent}%`,
251-
transform: `translateY(${activeTooltipTranslate})`,
252-
}}
226+
className="pointer-events-none absolute left-8 w-80 -translate-y-1/2"
227+
style={{ top: `${activeTopPercent}%` }}
253228
>
254229
<span className="dropdown-glass block rounded-xl p-3 text-left text-popover-foreground shadow-xl shadow-black/25">
255230
<span className="block max-w-full overflow-hidden text-ellipsis whitespace-nowrap text-sm font-medium leading-5">
@@ -308,7 +283,7 @@ function TimelineMinimapNavigationButton({
308283
className={cn(
309284
"absolute left-1 z-10 inline-flex -translate-x-1/2 opacity-0 transition-opacity duration-150 hover:opacity-100 focus-within:opacity-100",
310285
interactive ? "pointer-events-auto" : "pointer-events-none",
311-
previous ? "bottom-[calc(100%+2px)]" : "top-[calc(100%+2px)]",
286+
previous ? "bottom-[calc(100%+6px)]" : "top-[calc(100%+6px)]",
312287
)}
313288
/>
314289
}

0 commit comments

Comments
 (0)