Skip to content

Commit cee7ea2

Browse files
fix(web): Cite button opens below the selection, not under the pointer
After a mouse selection on assistant text, the Cite button opened with its corner at the mouseup point, so the next click a few px away (often to clear the selection) landed on it and added an unintended citation. Anchor it below the end of the selection for mouse selections too, as keyboard selections and off-text releases already do. The terminal's selection actions are unchanged. Fixes #29209 Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 5be76ab commit cee7ea2

1 file changed

Lines changed: 2 additions & 11 deletions

File tree

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

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export function AssistantSelectionToolbar({
5151
useEffect(() => {
5252
if (!viewport) return;
5353
const clear = () => setSelection(null);
54-
const update = (pointer: SelectionActionPoint | null) => {
54+
const update = () => {
5555
const nativeSelection = window.getSelection();
5656
const captured = captureAssistantTextSelection(viewport, nativeSelection);
5757
const messageId = captured?.source.dataset.assistantCitationSource;
@@ -112,15 +112,6 @@ export function AssistantSelectionToolbar({
112112
return;
113113
}
114114
const rects = captured.range.getClientRects();
115-
const pointerOnText =
116-
pointer !== null &&
117-
Array.from(rects).some(
118-
(line) =>
119-
pointer.x >= line.left - 8 &&
120-
pointer.x <= line.right + 8 &&
121-
pointer.y >= line.top - 8 &&
122-
pointer.y <= line.bottom + 8,
123-
);
124115
setSelection({
125116
sourceAnchor: { source: captured.source, range: captured.range, viewport },
126117
citation: {
@@ -132,7 +123,7 @@ export function AssistantSelectionToolbar({
132123
position: resolveSelectionActionPosition({
133124
bounds: viewportRect,
134125
selectionRect: rects.item(rects.length - 1) ?? rect,
135-
pointer: pointerOnText ? pointer : null,
126+
pointer: null,
136127
viewport: { width: window.innerWidth, height: window.innerHeight },
137128
}),
138129
});

0 commit comments

Comments
 (0)