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

This commit is contained in:
oliver authored and GitHub committed 2026-10-11 20:19:13 -03:00
1 parent 662148dd29
commit 55fc13ff68
1 file changed
+10 -1
@@ -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 },
}),
});