Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(web): keep citation controls inside the message area #22293

Closedrookmate(GitHub profile, opens in a new tab)wants to merge 5 commits intomain fromrefs/pull/22293/headopened View on GitHub

Showing 11 changed files with 23 additions and 4 deletions (loading 10).

x
0 of 11 viewed, 11 left
23 additions and 4 deletionsapps/web/src/components/chat/AssistantCitationChip.tsxModified
View file
@@ -8,6 +8,7 @@
import {
useEffect,
useEffectEvent,
+ useLayoutEffect,
useRef,
useState,
type MouseEvent as ReactMouseEvent,
@@ -31,6 +32,7 @@
import { observeAssistantCitationCommentSource } from "./AssistantCitationSource";
import { composerFloatingLayerProps } from "./composerEventScope";
import { observeResize } from "~/lib/observeResize";
+import { assistantCitationAnchorRect } from "~/lib/assistantCitationPosition";
​
export function AssistantCitationChip({
citation,
@@ -59,6 +61,18 @@
const commentOpen = commentEditor?.open ?? false;
const sourceAnchor = commentEditor?.sourceAnchor;
const activeSourceAnchor = sourceAnchor === unavailableSourceAnchor ? undefined : sourceAnchor;
+ const boundary = activeSourceAnchor?.boundary;
+ const [boundaryRect, setBoundaryRect] = useState<
+ { element: HTMLElement; rect: Pick<DOMRect, "x" | "y" | "width" | "height"> } | undefined
+ >();
+ useLayoutEffect(() => {
+ if (!commentOpen || !boundary) return;
+ return observeResize(boundary, () => {
+ // Base UI compares rect values; resizing the same boundary element does not reposition it.