Skip to content

fix(theme-classic): render mobile HTML navbar items as list items - #12787

Open
arushii-codes wants to merge 1 commit into
meta:mainfrom
arushii-codes:fix/mobile-html-navbar-list-item
Open

arushii-codes wants to merge 1 commit into
meta:mainfrom
arushii-codes:fix/mobile-html-navbar-list-item

Conversation

@arushii-codes

@arushii-codes arushii-codes commented Oct 26, 2026 •

Copy link
Copy Markdown

Pre-flight checklist

  • I have read the Contributing Guidelines on pull requests.
  • If this is a code change: I have written unit tests and/or added dogfooding pages to fully verify the new behavior.
  • If this is a new API or substantial change: the PR has an accompanying issue (closes #0000) and the maintainers have approved on my working plan.

Motivation

Test Plan

Test links

Deploy preview: https://deploy-preview-_____--docusaurus-2.netlify.app/

Related issues/PRs

Summary by CodeRabbit

  • Bug Fixes
    • Mobile HTML navbar items now render as list items, matching dropdown items and improving consistency in mobile navigation.

@meta-cla

meta-cla Bot commented Oct 26, 2026

Copy link
Copy Markdown

Hi @arushii-codes!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at [email protected]. Thanks!

@coderabbitai

coderabbitai Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: ef518bd6-b7ec-44aa-a4db-f8f7548c28db
Commits

Reviewing files that changed from the base of the PR and between 4e6fe61 and 50eb444.

Files selected for processing: 2
  • packages/docusaurus-theme-classic/src/theme/NavbarItem/HtmlNavbarItem.tsx
  • packages/docusaurus-theme-classic/src/theme/NavbarItem/__tests__/HtmlNavbarItem.test.tsx

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

Walkthrough

HtmlNavbarItem now renders mobile items as <li> elements, as it already did for dropdown items. Tests cover mobile, desktop, and dropdown element tags, and verify the mobile item contains a “Docs” link.

Changes: Navbar item rendering

Layer / File(s) Summary
Element selection and test coverage
packages/docusaurus-theme-classic/src/theme/NavbarItem/HtmlNavbarItem.tsx, packages/docusaurus-theme-classic/src/theme/NavbarItem/__tests__/HtmlNavbarItem.test.tsx
Mobile and dropdown items render as <li> elements. Other desktop items render as <div> elements. Tests check these tags and the mobile “Docs” link.

Priority: Low

Estimated code review effort: 2 (Simple) | ~8 minutes

Change: Bug fix

Merge Risk: Minimal · up to 50eb4

The navbar rendering change has no identified merge-blocking risk.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: rendering mobile HTML navbar items as list items.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

@netlify

netlify Bot commented Oct 26, 2026

Copy link
Copy Markdown

✅ [V2]

Built without sensitive environment variables

Name Link
🔨 Latest commit 50eb444
🔍 Latest deploy log https://app.netlify.com/projects/docusaurus-2/deploys/6adf955f9c642da6a6c3c8bf
😎 Deploy Preview https://deploy-preview-12787--docusaurus-2.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@meta-cla meta-cla Bot added the CLA Signed Signed Facebook CLA label Oct 26, 2026
@meta-cla

meta-cla Bot commented Oct 26, 2026

Copy link
Copy Markdown

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

@10k11 10k11 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed and checked locally (built the packages, ran the PR's test file with vitest: 3/3 pass; ESLint reports nothing for it).

The fix is correct. NavbarMobilePrimaryMenu renders every item inside <ul className="menu__list">, so HtmlNavbarItem must emit an <li> when mobile is set. The menu__list-item class was already applied for mobile; only the tag was wrong. Dropdown items already used li, so behaviour there is unchanged.

Small, non-blocking suggestions:

  1. Stray blank line. The added empty line after const Comp = ... in HtmlNavbarItem.tsx is unrelated to the change; dropping it keeps the diff to one line.
  2. Test strength. The mobile test checks the tag only. Since the bug was an invalid div inside a ul, rendering the item inside a <ul className="menu__list"> and also asserting the menu__list-item class (and absence of navbar__item) would pin the real contract, so a future change of class logic is caught as well.
  3. The screen.getByRole('link', ...) check is a nice way to show the HTML is still injected. render is not auto-cleaned in this vitest setup, so if more screen queries are added later, call cleanup() or use the container queries to avoid cross-test matches.

FYI this overlaps with #12806, which makes the identical one-line change for #12578, so the maintainers may want to pick one.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed Signed Facebook CLA

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants