ant-design / ant-design/pro-components

🧐[问题]关于菜单根据路由自动选中特性

Open
#8,962 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
4.8k
Forks
1.4k
Avg merge
10h 44m
Merged PRs (30d)
3

Description

提问前先看看:

https://github.com/ryanhanwu/How-To-Ask-Questions-The-Smart-Way/blob/main/README-zh_CN.md

### 🧐 问题描述

https://procomponents.ant.design/components/layout
中有两句话提到了自动选中菜单:
ProLayout 会根据 location.pathname 来自动选中菜单,并且自动生成相应的面包屑。如果不想使用可以自己配置 selectedKeys 和 openKeys 来进行受控配置。

ProLayout 会自动生成菜单,同时根据 pathname 进行自动选中。配合 PageContainer 可以实现自动推算面包屑和页面标题。如果和 Umi 配置使用,只需要将 Page 的 props 交给 ProLayout,ProLayout 会根据 config 中的 routers 的配置自动生成菜单。

这导致我们有一批隐藏菜单分散在各个一级菜单中,通过按钮链接跳转时会自动选中一级菜单。
我们现在的需求是,对于隐藏菜单,不进行自动选中。

根据第一句描述,我们可能需要自己配置 selectedKeys 和 openKeys
请问我的思路正确吗?应该怎么处理?

Contributor guide

Open the contributing guide

Research direction

Read the ProLayout documentation linked in the issue, especially its pathname-based selection behavior and the selectedKeys/openKeys controlled configuration. Determine whether those props can prevent hidden routes from selecting a parent menu, and document the appropriate configuration or the remaining behavior that would need a feature change.

Written by the indexing model from the issue text.

Assessment

Tech stack
react, typescript
Domain
frontend
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.