authorgravatar for 97427849+flamboh@users.noreply.github.comoliver <97427849+flamboh@users.noreply.github.com> 2026-10-11 16:19:13-07:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2026-10-11 20:19:13-03:00
log55fc13ff68d2598b0613721041533dd1160bc5bd
tree49989c492d10e07c0b65b2f6c992154097598992
parent662148dd296984d11b40863ce6f90ead9c26396e
signature Signed by PGP key B5690EEEBB952194

fix(web): Cite button stays anchored to the selected text (#17650)


1 files changed, 10 insertions(+), 1 deletions(-)

apps/web/src/components/chat/AssistantSelectionToolbar.tsx+10-1
...@@ -61,6 +61,15 @@ export function AssistantSelectionToolbar({...@@ -61,6 +61,15 @@ export function AssistantSelectionToolbar({
61 return;61 return;
62 }62 }
63 const rects = captured.range.getClientRects();63 const rects = captured.range.getClientRects();
64 const pointerOnText =
65 pointer !== null &&
66 Array.from(rects).some(
67 (line) =>
68 pointer.x >= line.left - 8 &&
69 pointer.x <= line.right + 8 &&
70 pointer.y >= line.top - 8 &&
71 pointer.y <= line.bottom + 8,
72 );
64 setSelection({73 setSelection({
65 sourceAnchor: { source: captured.source, range: captured.range, viewport },74 sourceAnchor: { source: captured.source, range: captured.range, viewport },
66 citation: {75 citation: {
...@@ -72,7 +81,7 @@ export function AssistantSelectionToolbar({...@@ -72,7 +81,7 @@ export function AssistantSelectionToolbar({
72 position: resolveSelectionActionPosition({81 position: resolveSelectionActionPosition({
73 bounds: viewportRect,82 bounds: viewportRect,
74 selectionRect: rects.item(rects.length - 1) ?? rect,83 selectionRect: rects.item(rects.length - 1) ?? rect,
75 pointer,84 pointer: pointerOnText ? pointer : null,
76 viewport: { width: window.innerWidth, height: window.innerHeight },85 viewport: { width: window.innerWidth, height: window.innerHeight },
77 }),86 }),
78 });87 });