Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion apps/web/src/components/chat/ComposerCommandMenu.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { type ProjectEntry, type ModelSlug, type ProviderKind } from "@t3tools/contracts";
import { memo } from "react";
import { memo, useEffect, useRef } from "react";
import { type ComposerSlashCommand, type ComposerTriggerKind } from "../../composer-logic";
import { BotIcon } from "lucide-react";
import { cn } from "~/lib/utils";
Expand Down Expand Up @@ -82,8 +82,17 @@ const ComposerCommandMenuItem = memo(function ComposerCommandMenuItem(props: {
isActive: boolean;
onSelect: (item: ComposerCommandItem) => void;
}) {
const ref = useRef<HTMLDivElement>(null);

useEffect(() => {
if (props.isActive) {
ref.current?.scrollIntoView({ block: "nearest" });
}
}, [props.isActive]);

return (
<CommandItem
ref={ref}
value={props.item.id}
className={cn(
"cursor-pointer select-none gap-2",
Expand Down