Skip to content

Navbar Dropdown items with a "to" tag cant be clicked on mobile #11049

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

Closed
4 of 7 tasks
LostAndDead opened this issue Mar 30, 2025 · 4 comments · Fixed by #11053
Closed
4 of 7 tasks

Navbar Dropdown items with a "to" tag cant be clicked on mobile #11049

LostAndDead opened this issue Mar 30, 2025 · 4 comments · Fixed by #11053
Labels
bug An error in the Docusaurus core causing instability or issues with its execution

Comments

@LostAndDead
Copy link

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

When using a navbar dropdown item with a "to" tag it cant be clicked on mobile

If you have a navbar item as below

        {
          type: 'dropdown',
          label: 'Extraction',
          position: 'left',
          to: '/extraction/intro',
          items: [
            {
              label: 'MTP',
              to: '/extraction/mtp',
            },
            {
              label: 'ADB',
              to: '/extraction/adb/adb_extraction',
            },
            {
              label: 'Cloud',
              to: '/extraction/cloud',
            },
          ],
        },

If you open it on desktop the "Extraction" value shows the others when hovered and can be clicked to go to "/extraction/intro" but on mobile when clicked it opens the dropdown and clicking again closes it, its impossible to go to "/extraction/intro" on a mobile device using the navbar (unless you hold on "Extraction" and copy/follow the link)

this repo contains the problem. If you want a live example you can find it here

Reproducible demo

No response

Steps to reproduce

  1. Add dropdown navbar item with "to" value
  2. Open page on mobile
  3. Cant click on it to go to "to" value

Expected behavior

Desktop behaviour unchanged

On mobile clicking it once opens the menu, clicking again goes to the link, to close the menu click on the arrow

Actual behavior

You cant navigate to the url

Your environment

  • Public source code:
  • Public site URL:
  • Docusaurus version used:
  • Environment name and version (e.g. Chrome 89, Node.js 16.4):
  • Operating system and version (e.g. Ubuntu 20.04.2 LTS):

Self-service

  • I'd be willing to fix this bug myself.
@LostAndDead LostAndDead added bug An error in the Docusaurus core causing instability or issues with its execution status: needs triage This issue has not been triaged by maintainers labels Mar 30, 2025
@slorber
Copy link
Collaborator

slorber commented Apr 1, 2025

I see thanks, it seems we have this issue for a few years already.

Here's a PR with a fix: #11053

Note: if we make that mobile dropdown item clickable, then this means clicking on the link would navigate to the page (as you expect) but it also closes the mobile drawer.

What I mean is that now, we don't have a way to collapse/expand the mobile dropdown anymore 😅

Does it looks good to you if we split the mobile dropdown parent into 2 clickable areas?

Image

  • Clicking the label would navigate to the page
  • Clicking the arrow would expand the dropdown menu without navigating

@LostAndDead
Copy link
Author

I think it's good if it is split into 2 clickable areas, as you have shown.

Clicking the text takes you to the page, but clicking the arrow opens the collapsible items. It more aligns with the behaviour on desktop

@slorber
Copy link
Collaborator

slorber commented Apr 1, 2025

I have split the component into label/button.

Can you please let me know if this UX makes sense?

PR: #11053

Preview: https://deploy-preview-11053--docusaurus-2.netlify.app/

Do you see any UX problem to report, or can I settle into this behavior and cleanup the implementation?

@LostAndDead
Copy link
Author

I dont see any problems with it, behaves on my phone as I would expect and desktop behaviour remains unchanged.

@slorber slorber removed the status: needs triage This issue has not been triaged by maintainers label Apr 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An error in the Docusaurus core causing instability or issues with its execution
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants