Skip to content

Dropdown items of navbar doesn't work well. #8094

@AnteeHub

Description

@AnteeHub

Have you read the Contributing Guidelines on issues?

Prerequisites

  • I'm using the latest version of Docusaurus.
  • I have tried the npm run clear or yarn clear command.
  • I have tried rm -rf node_modules yarn.lock package-lock.json and re-installing packages.
  • I have tried creating a repro with https://new.docusaurus.io.
  • I have read the console error message carefully (if applicable).

Description

I create a new docusaurus project and add a dropdown item for navbar.
And I find that the dropdown items are all actived on the navbar.

Reproducible demo

https://stackblitz.com/edit/github-rgqq1d?file=docusaurus.config.js

Steps to reproduce

  1. Init the project with docusaurus v2.1.0
  2. keep the sidebars config type as autogenerated ( I didn't modify it)
  3. Add 1 dropdown item into navbar items
navbar: {
        // ...
        items: [
           // ...
            {
                type: "dropdown",
                position: "left",
                label: "dropdown",
                items: [
                    {
                        type: "doc",
                        docId: "tutorial-extras/translate-your-site",
                        label: "dropdown 1",
                    },
                    {
                        type: "doc",
                        docId: "tutorial-extras/manage-docs-versions",
                        label: "dropdown 2",
                    },
                ],
            },
            // ...
        ],
    },

Expected behavior

There should be only 1 navbar item actived in the dropdown menu.
Like this:
image

Actual behavior

All of the dropdown items being actived, including the doc navbar item.
If you add 2 dropdown items, all of the items in both dropdowns are actived.
image

Your environment

Self-service

  • I'd be willing to fix this bug myself.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugAn error in the Docusaurus core causing instability or issues with its executionclosed: duplicateThis issue or pull request already exists in another issue or pull request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions