Skip to content

Commit

Permalink
fix: made sidebar collapse when screen is smaller (#4822)
Browse files Browse the repository at this point in the history
Fixed sidebar collapsing when screen is smaller
  • Loading branch information
lucaseduoli authored Nov 25, 2024
1 parent 84981fc commit 6f2cc34
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/frontend/src/components/ui/sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { VariantProps, cva } from "class-variance-authority";
import { PanelLeft } from "lucide-react";
import * as React from "react";

import { useIsMobile } from "@/hooks/use-mobile";
import { cn } from "../../utils/utils";
import ShadTooltip from "../shadTooltipComponent";
import { Button } from "./button";
Expand Down Expand Up @@ -164,6 +165,7 @@ const Sidebar = React.forwardRef<
ref,
) => {
const { state, setOpen, defaultOpen } = useSidebar();
const isMobile = useIsMobile();

React.useEffect(() => {
if (collapsible === "none") {
Expand All @@ -173,6 +175,16 @@ const Sidebar = React.forwardRef<
}
}, [collapsible]);

React.useEffect(() => {
if (collapsible !== "none") {
if (isMobile) {
setOpen(false);
} else {
setOpen(defaultOpen);
}
}
}, [isMobile]);

if (collapsible === "none") {
return (
<div
Expand Down

0 comments on commit 6f2cc34

Please sign in to comment.