Skip to content

[bug]: sidebar "state" via Hook "useSidebar" doesn't change on mobile #7808

@jakobwgnr

Description

@jakobwgnr

Describe the bug

When expanding or collapsing the sidebar in desktop view the state from useSidebar hook changes from collapsed to expanded as expected.

When expanding or collapsing the sidebar in mobile view the state stays unchanged as collapsed

Affected component/components

Sidebar

How to reproduce

  1. use the shadcn sidebar in any project (as per tutorial here)
  2. log the state in the console
  3. toggle the state in desktop view
  4. toggle the state in mobile view (e.g. via chrome dev tools)
  const { state, isMobile } = useSidebar();
  console.log("current state", state, "isMobile", isMobile);

Codesandbox/StackBlitz link

n/a

Logs

mobile:
AppSidebar.tsx:110 current state collapsed isMobile true
AppSidebar.tsx:110 current state collapsed isMobile true

desktop:
AppSidebar.tsx:110 current state expanded isMobile false
AppSidebar.tsx:110 current state collapsed isMobile false

System Info

Windows 11, MS Edge

Before submitting

  • I've made research efforts and searched the documentation
  • I've searched for existing issues

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions