ant-design / ant-design/pro-components

🧐[问题]对menuItemRender实现拖拽移动功能的最佳实践

Open
#7,465 0 comments 0 reactions 0 assignees View on GitHub
🤷🏼 How to use
Dominant language
TypeScript
Stars
4.8k
Forks
1.4k
Avg merge
10h 44m
Merged PRs (30d)
3

Description

### 🧐 问题描述
我的项目的菜单是通过`ProLayout高级布局`的运行时配置实现的,并且菜单项是通过`menuItemRender`这个回调函数编写的。
我希望能够实现menuItem在menu中进行拖拽移动,我使用了一些能够实现树组件中,对叶子节点和根节点的拖拽移动。比如`dnd-kit`,`react-dnd-treeview`

但是`dnd-kit`的文档和示例代码都让人难以学习,而像`react-dnd-treeview`,它封装了一个Tree组件,需要将`一个个节点传进去`,于是我将menuItemRender的函数返回的组件传入Tree中。在使用后发现并不能满足我的需求,**因为缺少了css样式**

我将新的菜单项的组件放到了`menuExtraRender`中,或者可以连同之前的`menuExtraRender`放入`menuRender`中?但是这依然会缺少css样式

我想了解:对menuItemRender实现拖拽移动功能,是否有最佳实践?对于菜单项这种`树型结构的拖拽移动`,我没有在网络上看到使用procomponents实现的例子

就像这样:
![](https://qiankun825.oss-cn-hangzhou.aliyuncs.com/img/拖拽移动.gif)

Contributor guide

Open the contributing guide

Research direction

Start with the ProLayout runtime configuration and the menuItemRender, menuExtraRender, and menuRender entry points described in the issue. Compare the menu tree structure with the mentioned dnd-kit and react-dnd-treeview approaches, paying attention to the reported missing CSS. Done means documenting or demonstrating a supported way to drag and move leaf and root menu nodes while preserving menu styling.

Written by the indexing model from the issue text.

Assessment

Tech stack
css, react, typescript
Domain
frontend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.