Skip to content

fix(navbar): 统一导航配色,优化下拉交互与定位 - #124

Merged
TechQuery merged 4 commits into
mainfrom
fix/main-navbar-interactions
Nov 23, 2026
Merged

TechQuery merged 4 commits into
mainfrom
fix/main-navbar-interactions

Conversation

@dethan3

@dethan3 dethan3 commented Nov 20, 2026 •

Copy link
Copy Markdown
Member

Checklist(清单):

  • Labels
  • Assignees
  • Reviewers

变更内容

  • 统一直接链接与下拉按钮的默认文字颜色,保留悬停、键盘聚焦和当前页面反馈。
  • 桌面鼠标悬停展开菜单,移入菜单或跨越间隙时保持展开,离开后收起;触屏保留点击切换。
  • 菜单与按钮中心对齐,靠近视口或移动抽屉边缘时自动避让,并统一深色配色。
  • 桌面导航使用普通容器,移动端保留 Drawer,修复刷新时“关于”自动获得焦点的问题。
  • 按上游文档使用 NavItem > Menu 结构,并补齐导航按钮的 aria-controls 关联。

交互定制说明

Bootstrap 的一级菜单默认通过点击展开,本 PR 的桌面悬停展开、菜单居中及边缘避让属于本站的 UX 定制。实现优先复用 Idea React 的定位和键盘操作能力,局部样式使用 CSS Modules。

Closes #123

Summary by CodeRabbit

  • 新功能
    • 桌面端导航菜单支持悬停展开,并会根据触发项和菜单面板的位置调整显示位置。
    • 导航菜单和抽屉会根据屏幕宽度切换布局;切换至桌面布局时,抽屉自动关闭。
    • 导航链接和菜单项会显示当前页面状态,并提供清晰的键盘焦点提示。

Use shared dark-theme colors for links and dropdown triggers while preserving
hover, keyboard focus, and current-page feedback.

Open dropdowns on desktop mouse hover, retain touch click toggling, and bridge
the trigger-to-menu gap. Center menus on their triggers with viewport and
mobile drawer edge avoidance through Idea React positioning.

Render desktop navigation outside a dialog to prevent automatic focus on
About after refresh, while retaining the mobile drawer and keyboard focus
restoration.

Validated Simplified Chinese and English navigation with mouse, keyboard,
mobile touch, and mixed-input simulations. TypeScript, ESLint, formatting,
and production build checks passed.
Wrap each dropdown Menu in NavItem and restore its default div root to match
Bootstrap 6 and Idea React navbar examples without nesting list items.

Connect NavbarToggler aria-controls to a stable navigation ID shared by the
desktop container and mobile drawer across breakpoint changes.

Desktop hover opening and trigger-centered menus with edge avoidance are
intentional UX customizations requested for this site. Bootstrap deliberately
uses click-to-open menus; this change does not treat that upstream default as
a bug. Touch clicking and keyboard focus behavior remain supported.
@dethan3 dethan3 self-assigned this Nov 20, 2026
@dethan3 dethan3 added the enhancement Some improvements label Nov 20, 2026
@coderabbitai

coderabbitai Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

Explain Change →

Note

.coderabbit.yaml has unrecognized properties

CodeRabbit is using all valid settings from your configuration. Unrecognized properties (listed below) have been ignored and may indicate typos or deprecated fields that can be removed.

Parsing warnings: 1

Validation error: Unrecognized key: "code_generation" at "reviews"
Configuration instructions

  • Please see the configuration documentation for more information.
  • You can also validate your configuration using the online YAML validator.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

No actionable comments were generated in the recent review.

Walkthrough

主导航新增桌面下拉菜单的悬停交互和定位样式,并按屏幕断点切换桌面导航与移动端抽屉。idea-react 样式表版本更新为 3.0.0-rc.6。

Changes: 主导航菜单

Layer / File(s) Summary
菜单样式与交互
components/Navigator/MainNavigator.module.css, components/Navigator/MainNavigatorMenu.tsx
新增链接和菜单项的默认、悬停、焦点及当前项样式。桌面菜单根据触发器和面板宽度调整水平位置;鼠标进入时打开,离开后延迟关闭。
响应式导航集成
components/Navigator/MainNavigator.tsx, pages/_document.tsx
MainNavigator 根据 (min-width: 1024px) 切换桌面导航与抽屉布局,并将菜单项、当前路径和关闭回调传入 MainNavigatorMenu。样式表版本更新为 3.0.0-rc.6。

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Feature · Severity of issue fixed: Medium

Sequence Diagram(s)

sequenceDiagram
  participant MainNavigator
  participant MainNavigatorMenu
  participant Menu
  MainNavigator->>MainNavigatorMenu: 传入桌面状态和当前路径
  MainNavigatorMenu->>Menu: 渲染菜单项和活动状态
  Menu->>MainNavigatorMenu: 鼠标进入菜单触发区域
  MainNavigatorMenu->>Menu: 打开菜单并设置水平偏移
Loading

Possibly related PRs

Suggested reviewers: techquery, luojiyin1987

Merge Risk: Minimal · up to d1289 · assessed changes only

Path filters excluded changed files. This rating applies only to the assessed changes.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed 标题“fix(navbar): 统一导航配色,优化下拉交互与定位”概括了主要变更:统一导航链接与下拉触发器配色,并优化桌面端下拉菜单的悬停交互与居中定位。变更集中包含 MainNavigator 与 MainNavigatorMenu 的新增逻辑、CSS 配色规则,以及 idea-react 样式表升级,标题与这些主要内容相符。标题使用 conventional commit 前缀 fix(nav…
Linked Issues check Passed 【#123 需求对照】

1. 未选中导航项默认文字颜色统一:MainNavigator.module.css 为链接和菜单项定义默认、悬停、焦点和当前项颜色,并使当前项加粗。满足需求,同时保留悬停、键盘聚焦和当前页面反馈。

2. 桌面端悬停展开、移入菜单保持展开、离开后收起:MainNavigatorMenu.tsx 仅对鼠标指针启用悬停打开,离开后延迟 200 毫秒关闭;若焦点仍在面板内则不…
Out of Scope Changes check Passed 【范围判断】

- MainNavigator.tsx 与 MainNavigatorMenu.tsx 的改动直接实现 #123 的桌面菜单交互、居中与避让,属于范围内。
- 移除 MainNavigatorDrawer 并将抽屉逻辑合并到主导航、桌面端改用普通容器、修复刷新时“关于”自动获得焦点、补齐 aria-controls:这些改动位于同一导航组件内,服务于导航结构与可访问性,与 #123…
Full details: Title check

Explanation

标题“fix(navbar): 统一导航配色,优化下拉交互与定位”概括了主要变更:统一导航链接与下拉触发器配色,并优化桌面端下拉菜单的悬停交互与居中定位。变更集中包含 MainNavigator 与 MainNavigatorMenu 的新增逻辑、CSS 配色规则,以及 idea-react 样式表升级,标题与这些主要内容相符。标题使用 conventional commit 前缀 fix(navbar),范围明确,长度适中。

Full details: Linked Issues check

Explanation

【#123 需求对照】

  1. 未选中导航项默认文字颜色统一:MainNavigator.module.css 为链接和菜单项定义默认、悬停、焦点和当前项颜色,并使当前项加粗。满足需求,同时保留悬停、键盘聚焦和当前页面反馈。

  2. 桌面端悬停展开、移入菜单保持展开、离开后收起:MainNavigatorMenu.tsx 仅对鼠标指针启用悬停打开,离开后延迟 200 毫秒关闭;若焦点仍在面板内则不关闭;卸载时清理计时器。触屏保留点击切换。键盘 Enter/Space 打开、Esc 关闭依赖 Idea React 与 Bootstrap 的既有键盘行为,PR 描述与提交信息报告已通过键盘模拟测试。本次评估仅依据摘要,未逐行核对键盘事件处理代码。

  3. 下拉面板与触发按钮居中、靠近视口或抽屉边缘时避让、菜单使用深色主题:MainNavigatorMenu.tsx 在触发器或面板尺寸变化时计算居中偏移并监听尺寸;CSS 设置菜单活动项颜色变量、变换原点和间隙,满足需求。

【结论】需求 1 至 3 的编码内容均有对应实现证据。未发现未满足的编码需求。

Full details: Out of Scope Changes check

Explanation

【范围判断】

  • MainNavigator.tsx 与 MainNavigatorMenu.tsx 的改动直接实现 #123 的桌面菜单交互、居中与避让,属于范围内。
  • 移除 MainNavigatorDrawer 并将抽屉逻辑合并到主导航、桌面端改用普通容器、修复刷新时“关于”自动获得焦点、补齐 aria-controls:这些改动位于同一导航组件内,服务于导航结构与可访问性,与 #123 的导航交互目标相关,不构成无关改动。
  • pages/_document.tsx 将 idea-react 样式表从 3.0.0-rc.4 升级为 3.0.0-rc.6:该升级是 PR 作者给出的依赖理由,用于获取导航所用的上游能力并删除冗余样式。该改动与导航功能相关。
  • 摘要显示的 package.json 与 pnpm-lock.yaml 属于 ignored_files,未检查其内容。依赖版本的实际影响无法从可审查证据中完全确认,但该限制不影响上述判断。

未发现与 #123 无关的功能变更。

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between b1a3778 and d128995.

Files ignored due to path filters: 2

  • package.json is excluded by none and included by none
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml, !pnpm-lock.yaml and included by none
Files selected for processing: 4

  • components/Navigator/MainNavigator.module.css
  • components/Navigator/MainNavigator.tsx
  • components/Navigator/MainNavigatorMenu.tsx
  • pages/_document.tsx

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

@TechQuery TechQuery left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

升级 https://github.com/idea2app/Idea-React/releases/tag/v3.0.0-rc.6 之后,一些 bug 应该就消失了。而且我觉得不需要抽两个独立组件出来就能解决问题,一个导航栏没这么复杂。

Keep desktop hover and center alignment on top of the upstream menu. Render the mobile drawer directly in MainNavigator and keep its menus in flow.
@dethan3

dethan3 commented Nov 23, 2026

Copy link
Copy Markdown
Member Author

升级 https://github.com/idea2app/Idea-React/releases/tag/v3.0.0-rc.6 之后,一些 bug 应该就消失了。而且我觉得不需要抽两个独立组件出来就能解决问题,一个导航栏没这么复杂。

感谢建议,我已经把组件升级到升级到 Idea React 3.0.0-rc.6 了,同步更新了样式依赖,并基于上游修复移除了冗余配置和样式。同时删除了 MainNavigatorDrawer,将响应式抽屉逻辑合回主导航,减少组件拆分。

目前仍保留一个 MainNavigatorMenu 包装,集中处理本站需要的桌面鼠标悬停、按钮与菜单中心对齐、间隙保护及键盘焦点协调。悬停和居中 Bootstrap 目前不支持,我建议加上这个交互。

Comment thread components/Navigator/MainNavigator.tsx Resolved
@TechQuery
TechQuery merged commit 528a7e1 into main Nov 23, 2026
5 checks passed
@TechQuery
TechQuery deleted the fix/main-navbar-interactions branch November 23, 2026 14:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Some improvements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[optimize] 统一主导航文字状态,优化下拉菜单的触发和对齐

3 participants