Skip to content

Commit d681dfe

Browse files
authored
Merge pull request #218 from Trynax/fix/input-overlay-messages
fix: input overlay covering messages
2 parents 8f8799c + 42105a9 commit d681dfe

File tree

3 files changed

+24
-6
lines changed

3 files changed

+24
-6
lines changed

src/app/(general)/_components/chat/chat.tsx

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { Logo } from "@/components/ui/logo";
1212
import { useSearchParams } from "next/navigation";
1313
import { WelcomeDialog } from "../welcome-dialog";
1414
import { Anvil } from "lucide-react";
15+
import { cn } from "@/lib/utils";
1516

1617
export const ChatContent = ({
1718
id,
@@ -40,7 +41,7 @@ export const ChatContent = ({
4041
return (
4142
<>
4243
<div className="bg-background relative flex h-full min-w-0 flex-col">
43-
{/* Messages - always shown */}
44+
{/* Messages - flex-1 to take available space */}
4445
<Messages
4546
chatId={id}
4647
isReadonly={isReadonly}
@@ -51,7 +52,7 @@ export const ChatContent = ({
5152
scrollToBottom={scrollToBottom}
5253
/>
5354

54-
{/* Input Container - absolutely positioned, contains greeting, input, and starter prompts */}
55+
{/* Input Container - normal flow no absolute positioning */}
5556
<motion.div
5657
initial={hasInitialMessages ? { y: 0 } : { y: "calc(-50vh + 50%)" }}
5758
animate={
@@ -64,7 +65,14 @@ export const ChatContent = ({
6465
ease: "easeInOut",
6566
duration: 0.4,
6667
}}
67-
className="absolute bottom-4 left-1/2 h-fit w-full max-w-3xl -translate-x-1/2 px-4"
68+
className={cn(
69+
"w-full px-4 pb-4",
70+
71+
!hasMessages &&
72+
!hasInitialMessages &&
73+
"absolute bottom-4 left-1/2 max-w-3xl -translate-x-1/2",
74+
(hasMessages || hasInitialMessages) && "mx-auto max-w-3xl",
75+
)}
6876
>
6977
{/* Greeting - only shown when no messages */}
7078
<AnimatePresence>

src/app/(general)/_components/chat/input/index.tsx

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,18 @@ const PureMultimodalInput: React.FC<Props> = ({
7777
const adjustHeight = () => {
7878
if (textareaRef.current) {
7979
textareaRef.current.style.height = "auto";
80-
textareaRef.current.style.height = `${textareaRef.current.scrollHeight + 2}px`;
80+
81+
const maxHeight = Math.min(
82+
window.innerHeight * 0.35 - 32,
83+
textareaRef.current.scrollHeight + 2,
84+
);
85+
if (textareaRef.current.scrollHeight + 2 <= maxHeight) {
86+
textareaRef.current.style.height = `${textareaRef.current.scrollHeight + 2}px`;
87+
textareaRef.current.style.overflowY = "hidden";
88+
} else {
89+
textareaRef.current.style.height = `${maxHeight}px`;
90+
textareaRef.current.style.overflowY = "auto";
91+
}
8192
}
8293
};
8394

@@ -417,7 +428,7 @@ const PureMultimodalInput: React.FC<Props> = ({
417428
value={input}
418429
onChange={handleInput}
419430
className={cn(
420-
"h-auto max-h-[calc(75dvh-4rem)] min-h-[48px] resize-none overflow-hidden border-0 bg-transparent px-4 py-3 !text-base shadow-none focus-visible:ring-0 dark:bg-transparent",
431+
"h-auto max-h-[calc(35dvh-2rem)] min-h-[48px] resize-none overflow-y-auto border-0 bg-transparent px-4 py-3 !text-base shadow-none focus-visible:ring-0 dark:bg-transparent",
421432
className,
422433
)}
423434
rows={2}

src/app/(general)/_components/chat/messages/index.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ const PureMessages: React.FC<Props> = ({
5050
ref={containerRef}
5151
className={cn(
5252
"relative flex h-full min-w-0 flex-1 flex-col gap-6 overflow-y-scroll py-8",
53-
messages.length > 0 && "mb-20",
5453
)}
5554
>
5655
{messages

0 commit comments

Comments
 (0)