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: unexpected toggling of groups with headings linked to the current page #3805

Open
olets opened this issue Apr 18, 2024 · 0 comments · May be fixed by #3806
Open

sidebar: unexpected toggling of groups with headings linked to the current page #3805

olets opened this issue Apr 18, 2024 · 0 comments · May be fixed by #3806
Labels
bug: pending triage Maybe a bug, waiting for confirmation

Comments

@olets
Copy link
Contributor

olets commented Apr 18, 2024

Describe the bug

Sidebar group headings can be linked. If a sidebar group is linked, visiting the page it's linked to will uncollapse the group. The effect is unexpected and can result in undesired uncollapsings.

Reproduction

  1. With the released version, replace docs/.vitepress/config/en.ts's sidebarGuide with the following.
    function sidebarGuide(): DefaultTheme.SidebarItem[] {
      return [
        {
          text: 'Introduction',
          collapsed: true,
          items: [
            {
              text: 'Group heading linked to "What is VitePress?"',
              link: 'what-is-vitepress',
              collapsed: true,
              items: [
                {
                  text: 'Another group heading linked to "What is VitePress?"',
                  link: 'what-is-vitepress',
                  collapsed: true,
                  items: [
                    {
                      text: 'What is VitePress?',
                      link: 'what-is-vitepress',
                    },
                  ],
                },
              ],
            },
            { text: 'Getting Started', link: 'getting-started' },
            { text: 'Routing', link: 'routing' },
            { text: 'Deploy', link: 'deploy' }
          ]
        },
        { text: 'What is VitePress?', link: 'what-is-vitepress',},
        {
          text: 'Writing',
          collapsed: false,
          items: [
            { text: 'Markdown Extensions', link: 'markdown' },
            { text: 'Asset Handling', link: 'asset-handling' },
            { text: 'Frontmatter', link: 'frontmatter' },
            { text: 'Using Vue in Markdown', link: 'using-vue' },
            { text: 'Internationalization', link: 'i18n' }
          ]
        },
        {
          text: 'Customization',
          collapsed: false,
          items: [
            { text: 'Using a Custom Theme', link: 'custom-theme' },
            {
              text: 'Extending the Default Theme',
              link: 'extending-default-theme'
            },
            { text: 'Build-Time Data Loading', link: 'data-loading' },
            { text: 'SSR Compatibility', link: 'ssr-compat' },
            { text: 'Connecting to a CMS', link: 'cms' }
          ]
        },
        {
          text: 'Experimental',
          collapsed: false,
          items: [
            { text: 'MPA Mode', link: 'mpa-mode' },
            { text: 'Sitemap Generation', link: 'sitemap-generation' }
          ]
        },
        { text: 'Config & API Reference', base: '/reference/', link: 'site-config' }
      ]
    }
  2. Run pnpm run docs
  3. Open http://localhost:<your port>/guide/routing in a browser
  4. Click on the text of the second sidebar item, "Group heading linked to "What is VitePress?"
  5. Confirm that it and its child group opens.

Expected behavior

Clicking a sidebar group's linked heading opens the link without toggling the group.

System Info

System:
    OS: macOS 14.3.1
    CPU: (8) arm64 Apple M1
    Memory: 191.89 MB / 16.00 GB
    Shell: 5.9 - /opt/homebrew/bin/zsh
  Binaries:
    Node: 18.12.0 - ~/.asdf/installs/nodejs/18.12.0/bin/node
    Yarn: 1.22.22 - /opt/homebrew/bin/yarn
    npm: 8.19.2 - ~/.asdf/installs/nodejs/18.12.0/bin/npm
    pnpm: 8.15.6 - ~/Library/pnpm/pnpm
    bun: 1.1.4 - ~/.bun/bin/bun
  Browsers:
    Brave Browser: 123.1.64.122
    Chrome: 123.0.6312.124
    Edge: 123.0.2420.97
    Safari: 17.3.1


### Additional context

_No response_

### Validations

- [X] Check if you're on the [latest VitePress version](https://github.com/vuejs/vitepress/releases/latest).
- [X] Follow our [Code of Conduct](https://vuejs.org/about/coc.html)
- [X] Read the [docs](https://vitepress.dev).
- [X] Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
@olets olets added the bug: pending triage Maybe a bug, waiting for confirmation label Apr 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug: pending triage Maybe a bug, waiting for confirmation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant