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

Sidebar menu: <ChevronRight /> icon is always displayed, regardless of the sub-items existence #1513

Open
GrungeElFz opened this issue Nov 22, 2024 · 0 comments

Comments

@GrungeElFz
Copy link

GrungeElFz commented Nov 22, 2024

Describe the bug

Current Behavior:

The <ChevronRight /> icon is always displayed in the sidebar menu, even when a menu item does not contain sub-items.

This is misleading to users as it suggests a clickable submenu exists when it does not.

Expected Behavior:

The <ChevronRight /> icon should only be displayed for menu items that contain sub-items.

i.e., when mainItem.items exists and has a length greater than 1.

Implementation:

A fix has been implemented to conditionally render the <ChevronRight /> icon based on the presence of sub-items in the merge request:

MR: feat (next): Added <ChevronRight />'s render condition, based on mainItem.items.length


Reproduction

Blocks:

  • shadcn-svelte@next add sidebar-07
  • shadcn-svelte@next add sidebar-08

Simply remove the navMain' s sub-items in the [ app-sidebar.svelte ]

↳ (src/lib/components/app-sidebar.svelte)

// This is sample data.
const data = {
  user: {
    name: 'shadcn',
    email: '[email protected]',
    avatar: '/avatars/shadcn.jpg'
  },
  teams: [
    { name: 'Acme Inc', logo: GalleryVerticalEnd, plan: 'Enterprise' },
    { name: 'Acme Corp.', logo: AudioWaveform, plan: 'Startup' },
    { name: 'Evil Corp.', logo: Command, plan: 'Free' }
  ],
  navMain: [
    {
      title: 'Playground',
      url: '#',
      icon: SquareTerminal,
      isActive: true,
      items: [
        // { title: 'History', url: '#' },
	// { title: 'Starred', url: '#' },
	// { title: 'Settings', url: '#' }
      ]

  // The rest of the code
};

System Info

System:
    OS: macOS 14.6.1
    CPU: (10) arm64 Apple M1 Pro
    Memory: 67.16 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh

  Binaries:
    Node: 22.11.0 - ~/.nvm/versions/node/v22.11.0/bin/node
    npm: 10.9.0 - ~/.nvm/versions/node/v22.11.0/bin/npm
    bun: 1.1.34 - /opt/homebrew/bin/bun

  Browsers:
    Brave Browser: 113.1.51.118
    Chrome: 131.0.6778.86
    Safari: 17.6

  npmPackages:
    @sveltejs/kit: ^2.8.1 => 2.8.1 
    bits-ui: ^1.0.0-next.58 => 1.0.0-next.58 
    lucide-svelte: ^0.456.0 => 0.456.0 
    mode-watcher: ^0.4.1 => 0.4.1 
    svelte: ^5.2.2 => 5.2.2

Severity

annoyance

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant