Skip to content

feat(theme/nav): support multiple level nested navigation items#2943

Merged
SoonIter merged 5 commits intomainfrom
syt/fix-nav-without-link
Dec 30, 2025
Merged

feat(theme/nav): support multiple level nested navigation items#2943
SoonIter merged 5 commits intomainfrom
syt/fix-nav-without-link

Conversation

@SoonIter
Copy link
Copy Markdown
Member

Summary

This PR adds support for multiple level nested navigation items in both desktop (HoverGroup) and mobile (NavScreenMenuItem) navigation components, along with comprehensive e2e tests.

Main Features

1. Multi-level Nested Navigation Support

  • HoverGroup now supports recursive rendering of nested navigation items with unlimited depth
  • NavScreenMenuItem now properly handles deeply nested navigation with expand/collapse functionality
  • Added depth prop to track nesting level (starts from 0)
  • Added data-depth attribute to all nav items for CSS targeting and testing

2. Visual Hierarchy

  • Nested items are displayed with progressive indentation: 8 + depth * 12 pixels
  • Flat structure without nested containers for better performance
  • Clear visual hierarchy through padding-left

3. Bug Fixes

  • Fixed icon animation not working when nav item has both link and items in NavScreenMenuItem
  • The --open class is now correctly applied to Link components with children

4. Comprehensive E2E Tests

  • Added test cases for 3-level deep nested navigation
  • Tests verify data-depth attributes at each level
  • Tests cover both desktop hover menu and mobile NavScreen interactions
  • Tests validate navigation to deeply nested pages

Changes

  • packages/core/src/theme/components/HoverGroup/ - Recursive nested item rendering
  • packages/core/src/theme/components/NavScreen/NavScreenMenuItem.tsx - Icon animation fix
  • e2e/fixtures/nav-link-items/ - Multi-level nested navigation test cases

Related Issue

N/A - Feature enhancement

Checklist

  • Tests updated (added comprehensive e2e tests for nested navigation)
  • Documentation updated (or not required)

Copilot AI review requested due to automatic review settings December 29, 2025 11:11
@netlify
Copy link
Copy Markdown

netlify Bot commented Dec 29, 2025

Deploy Preview for rspress-v2 ready!

Name Link
🔨 Latest commit 8c122f2
🔍 Latest deploy log https://app.netlify.com/projects/rspress-v2/deploys/69538683440e5c000809a1e1
😎 Deploy Preview https://deploy-preview-2943--rspress-v2.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

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

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Dec 29, 2025

Rsdoctor Bundle Diff Analysis

Found 3 projects in monorepo, 2 projects with changes.

📊 Quick Summary
Project Total Size Change
node 9.3 MB +24.8 KB (0.3%)
node_md 1.2 MB 0
web 15.1 MB +1.2 KB (0.0%)
📋 Detailed Reports (Click to expand)

📁 node

Path: website/doc_build/diff-rsdoctor/node/rsdoctor-data.json

📌 Baseline Commit: 899cac477c | PR: #2948

Metric Current Baseline Change
📊 Total Size 9.3 MB 9.3 MB +24.8 KB (0.3%)
📄 JavaScript 0 B 0 B 0
🎨 CSS 0 B 0 B 0
🌐 HTML 9.3 MB 9.3 MB +24.8 KB (0.3%)
📁 Other Assets 0 B 0 B 0

📦 Download Diff Report: node Bundle Diff

📁 web

Path: website/doc_build/diff-rsdoctor/web/rsdoctor-data.json

📌 Baseline Commit: 899cac477c | PR: #2948

Metric Current Baseline Change
📊 Total Size 15.1 MB 15.1 MB +1.2 KB (0.0%)
📄 JavaScript 14.4 MB 14.4 MB +1.2 KB (0.0%)
🎨 CSS 128.4 KB 128.4 KB +9.0 B (0.0%)
🌐 HTML 0 B 0 B 0
📁 Other Assets 526.0 KB 526.0 KB 0

📦 Download Diff Report: web Bundle Diff

Generated by Rsdoctor GitHub Action

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR implements multi-level nested navigation support for both desktop (HoverGroup) and mobile (NavScreenMenuItem) navigation components, enabling unlimited depth navigation hierarchies.

Key changes:

  • Recursive rendering of nested navigation items with visual hierarchy through progressive indentation
  • Type system updates to support recursive NavItem structures
  • Bug fix for icon animation in mobile navigation when items have both links and children
  • Comprehensive E2E tests validating 3-level deep navigation

Reviewed changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
packages/shared/src/types/theme/nav.ts Updated NavItemWithChildren and NavItemWithLinkAndChildren to use recursive NavItem[] type instead of NavItemWithLink[]
packages/shared/src/runtime-utils/sidebar.ts Enhanced matchNavbar to use normalizeHref for consistent active state matching
packages/core/src/theme/components/NavScreen/NavScreenMenuItem.tsx Fixed icon animation bug by adding href prop support and improving conditional rendering logic
packages/core/src/theme/components/Nav/NavMenu.tsx Refactored variable naming for consistency (item → menuItem)
packages/core/src/theme/components/HoverGroup/index.tsx Added HoverGroupItem component with recursive rendering and depth tracking for multi-level navigation
packages/core/src/theme/components/HoverGroup/index.scss Removed hardcoded padding-left to support dynamic indentation based on depth
packages/core/src/node/runtimeModule/siteData/normalizeThemeConfig.ts Removed unnecessary type annotation allowing recursive item processing
packages/core/src/node/auto-nav-sidebar/walk.ts Improved error handling with createError utility and better file existence checking
e2e/fixtures/nav-link-items/index.test.ts Added comprehensive tests for 3-level nested navigation with depth attribute validation
e2e/fixtures/nav-link-items/doc/_nav.json Added multi-level nested navigation test data structure
e2e/fixtures/nav-link-items/doc/nested-items/*.md Added test fixture pages for nested navigation items

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/core/src/theme/components/HoverGroup/index.tsx
Comment thread packages/core/src/node/auto-nav-sidebar/walk.ts
SoonIter and others added 3 commits December 29, 2025 20:00
Added tag display functionality to HoverGroup component to maintain consistency with NavScreenMenuItem. Tags will now be displayed next to navigation items in dropdown menus.

Changes:
- Import Tag component from @theme
- Add tag display in all navigation item render cases
- Update styles to support flex layout with gap for tags

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@SoonIter SoonIter merged commit 0432fc8 into main Dec 30, 2025
9 checks passed
@SoonIter SoonIter deleted the syt/fix-nav-without-link branch December 30, 2025 09:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants