Skip to content

Commit f5551ce

Browse files
committed
fix(web): long quote popovers fade at the bottom while more is below
1 parent 0947951 commit f5551ce

1 file changed

Lines changed: 26 additions & 6 deletions

File tree

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

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,12 @@ import {
1717
assistantCitationHash,
1818
assistantCitationNavigation,
1919
} from "../../lib/assistantCitationNavigation";
20+
import { cn } from "~/lib/utils";
2021
import { ContextChip, ContextChipAction, ContextChipLabel } from "../ContextChip";
2122
import { ContextChipPopover } from "../contextChipParts";
2223
import { Button } from "../ui/button";
2324
import { Popover, PopoverClose, PopoverPopup, PopoverTrigger } from "../ui/popover";
25+
import { getVirtualizedScrollFadeClassName } from "../ui/scroll-area";
2426
import { AssistantCitationCommentEditor } from "./AssistantCitationCommentEditor";
2527
import { resolveAssistantCitationCommentDismissal } from "./assistantCitationCommentDismissal";
2628
import { observeAssistantCitationCommentSource } from "./AssistantCitationSource";
@@ -131,12 +133,7 @@ export function AssistantCitationChip({
131133
copyMarkdown={serializeAssistantCitation(citation)}
132134
>
133135
<div className="space-y-3 p-1 text-sm">
134-
<div className="max-h-64 space-y-3 overflow-y-auto whitespace-pre-wrap wrap-break-word">
135-
<blockquote className="border-l-2 border-border pl-3 text-muted-foreground">
136-
{citation.text}
137-
</blockquote>
138-
{citation.comment ? <p>{citation.comment}</p> : null}
139-
</div>
136+
<AssistantCitationQuote citation={citation} />
140137
<PopoverClose
141138
render={<Button variant="outline" size="sm" render={<Link {...sourceLinkProps} />} />}
142139
>
@@ -240,3 +237,26 @@ export function AssistantCitationChip({
240237
</ContextChip>
241238
);
242239
}
240+
241+
function AssistantCitationQuote({ citation }: { citation: AssistantCitation }) {
242+
const [fadeBottom, setFadeBottom] = useState(false);
243+
const updateFade = (element: HTMLElement) =>
244+
setFadeBottom(element.scrollHeight - element.clientHeight - element.scrollTop > 1);
245+
return (
246+
<div
247+
ref={(element) => {
248+
if (element) updateFade(element);
249+
}}
250+
onScroll={(event) => updateFade(event.currentTarget)}
251+
className={cn(
252+
"max-h-64 space-y-3 overflow-y-auto whitespace-pre-wrap wrap-break-word",
253+
getVirtualizedScrollFadeClassName({ top: false, bottom: fadeBottom }),
254+
)}
255+
>
256+
<blockquote className="border-l-2 border-border pl-3 text-muted-foreground">
257+
{citation.text}
258+
</blockquote>
259+
{citation.comment ? <p>{citation.comment}</p> : null}
260+
</div>
261+
);
262+
}

0 commit comments

Comments
 (0)