[Video attached] My Sidebar is not sticking

Hello. I am trying to keep my sidebar stay stuck to the left side of the screen but it seems to ignore the sticky positioning, getting scrolling up with the content on the right side. How do I resolve this issue? Thanks in advance.
8 Replies
Mannix
Mannix•3mo ago
is the sidebar a flex child?
Shayokh
ShayokhOP•3mo ago
"use client";

import { useEffect, useState } from "react";
import { IoSend } from "react-icons/io5";
import {
GetChatHistoryAction,
handleMessageSubmission,
} from "@/app/actions/interview-new";
import { Textarea } from "@/components/ui/textarea";
import type { TypeGetChatHistory } from "@/types/interview-types";
import NewChatIndicator from "../../_components/NewChatIndicator";
import ChatStructure from "./ChatStructure";

export default function Conversation({ routeId }: { routeId: string }) {
const [result, setResult] = useState<TypeGetChatHistory>();

useEffect(() => {
GetChatHistoryAction(routeId).then((res) => {
setResult(res);
});
}, [routeId]);

return (
<section className="relative w-full h-screen">
{result == null ? (
<p>Loading...</p>
) : !result?.success ? (
<p className="text-red-600">Failed to get interview history</p>
) : result?.data.chatHistory.length === 0 ? (
<NewChatIndicator />
) : (
<ChatStructure chatHistory={result.data.chatHistory} />
)}

{/* TODO: We need to rerender when we get the response back!!! */}
<form action={handleMessageSubmission}>
<input type="hidden" name="routeId" value={routeId} />

<div className="sticky flex justify-center items-end gap-x-3 w-full bottom-6">
<Textarea
name="message-textarea"
placeholder="Type your message here."
className="w-[90%] max-h-[8rem]"
/>

<button
type="submit"
className="bg-neutral-800 p-3 rounded-full hover:cursor-pointer hover:bg-neutral-700 transition"
>
<IoSend color="#ffffff" size={18} />
</button>
</div>
</form>
</section>
);
}
"use client";

import { useEffect, useState } from "react";
import { IoSend } from "react-icons/io5";
import {
GetChatHistoryAction,
handleMessageSubmission,
} from "@/app/actions/interview-new";
import { Textarea } from "@/components/ui/textarea";
import type { TypeGetChatHistory } from "@/types/interview-types";
import NewChatIndicator from "../../_components/NewChatIndicator";
import ChatStructure from "./ChatStructure";

export default function Conversation({ routeId }: { routeId: string }) {
const [result, setResult] = useState<TypeGetChatHistory>();

useEffect(() => {
GetChatHistoryAction(routeId).then((res) => {
setResult(res);
});
}, [routeId]);

return (
<section className="relative w-full h-screen">
{result == null ? (
<p>Loading...</p>
) : !result?.success ? (
<p className="text-red-600">Failed to get interview history</p>
) : result?.data.chatHistory.length === 0 ? (
<NewChatIndicator />
) : (
<ChatStructure chatHistory={result.data.chatHistory} />
)}

{/* TODO: We need to rerender when we get the response back!!! */}
<form action={handleMessageSubmission}>
<input type="hidden" name="routeId" value={routeId} />

<div className="sticky flex justify-center items-end gap-x-3 w-full bottom-6">
<Textarea
name="message-textarea"
placeholder="Type your message here."
className="w-[90%] max-h-[8rem]"
/>

<button
type="submit"
className="bg-neutral-800 p-3 rounded-full hover:cursor-pointer hover:bg-neutral-700 transition"
>
<IoSend color="#ffffff" size={18} />
</button>
</div>
</form>
</section>
);
}
Layout -
import type React from "react";
import Sidebar from "./_components/Sidebar";
import "@/app/globals.css";

export default function RootLayout({
children,
}: Readonly<{
children: React.ReactNode;
}>) {
return (
<main className="flex" suppressHydrationWarning>
<Sidebar />

{/* Right side content */}
{children}
</main>
);
}
import type React from "react";
import Sidebar from "./_components/Sidebar";
import "@/app/globals.css";

export default function RootLayout({
children,
}: Readonly<{
children: React.ReactNode;
}>) {
return (
<main className="flex" suppressHydrationWarning>
<Sidebar />

{/* Right side content */}
{children}
</main>
);
}
Shayokh
ShayokhOP•3mo ago
Shayokh
ShayokhOP•3mo ago
Yes sir
Mannix
Mannix•3mo ago
if the sidebar is a flex child you need to add align-self: start right now it is stretched that is why it's not working
Shayokh
ShayokhOP•3mo ago
No description
Shayokh
ShayokhOP•3mo ago
I just added it. But the behavior persists
Mannix
Mannix•3mo ago
remove h-screen h-screen is height: 100vh 😉 and you don't want that

Did you find this page helpful?