From 55fc13ff68d2598b0613721041533dd1160bc5bd Mon Sep 17 00:00:00 2001 From: oliver <97427849+flamboh@users.noreply.github.com> Date: Sun, 11 Oct 2026 16:19:13 -0700 Subject: [PATCH] fix(web): Cite button stays anchored to the selected text (#17650) --- .../src/components/chat/AssistantSelectionToolbar.tsx | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/apps/web/src/components/chat/AssistantSelectionToolbar.tsx b/apps/web/src/components/chat/AssistantSelectionToolbar.tsx index ff03524cfef28dcac75e568d623ab9ca9191d1d1..156a773e0211ad460d8544e1ab613908444d1ef5 100644 --- a/apps/web/src/components/chat/AssistantSelectionToolbar.tsx +++ b/apps/web/src/components/chat/AssistantSelectionToolbar.tsx @@ -61,6 +61,15 @@ export function AssistantSelectionToolbar({ return; } const rects = captured.range.getClientRects(); + const pointerOnText = + pointer !== null && + Array.from(rects).some( + (line) => + pointer.x >= line.left - 8 && + pointer.x <= line.right + 8 && + pointer.y >= line.top - 8 && + pointer.y <= line.bottom + 8, + ); setSelection({ sourceAnchor: { source: captured.source, range: captured.range, viewport }, citation: { @@ -72,7 +81,7 @@ export function AssistantSelectionToolbar({ position: resolveSelectionActionPosition({ bounds: viewportRect, selectionRect: rects.item(rects.length - 1) ?? rect, - pointer, + pointer: pointerOnText ? pointer : null, viewport: { width: window.innerWidth, height: window.innerHeight }, }), }); -- 2.54.0