Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug]: Sidebar horizontal scroll bar appear when expand #5780

Open
2 tasks done
JingerTea opened this issue Nov 9, 2024 · 1 comment
Open
2 tasks done

[bug]: Sidebar horizontal scroll bar appear when expand #5780

JingerTea opened this issue Nov 9, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@JingerTea
Copy link

Describe the bug

When the sidebar transitions from collapsed to expanded state, a horizontal scrollbar briefly appears for about 1 second during the animation. This creates an undesirable visual effect and slight layout shift.

Affected component/components

  • Sidebar - SidebarContent

How to reproduce

  1. Implement the Sidebar component with collapsible functionality
  2. Set the initial state to collapsed
  3. Click the toggle button to expand the sidebar
  4. Observe the brief appearance of a horizontal scrollbar during the expansion animation

Codesandbox/StackBlitz link

import { Sidebar, SidebarContent, SidebarTrigger } from "@/components/ui/sidebar" export default function Demo() { return ( {/ Content that might cause overflow /}

Some content here...

) }

Logs

No response

System Info

- Browser: Chrome, Firefox, Safari (issue appears in all major browsers)
- OS: Cross-platform issue
- React version: 18.x
- Next.js version: 15.x

Before submitting

  • I've made research efforts and searched the documentation
  • I've searched for existing issues
@JingerTea JingerTea added the bug Something isn't working label Nov 9, 2024
@JingerTea
Copy link
Author

To fix this we need to modify line in sidebar.tsx, this will resolve overflow issue when expand sidebar

const SidebarContent = React.forwardRef<
  HTMLDivElement,
  React.ComponentProps<"div">
>(({ className, ...props }, ref) => {
  return (
    <div
      ref={ref}
      data-sidebar="content"
      className={cn(
        "flex min-h-0 flex-1 flex-col gap-2 overflow-y-auto overflow-x-hidden",
        "group-data-[collapsible=icon]:overflow-hidden",
        className
      )}
      {...props}
    />
  )
})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant