Skip to content

官网Dropdown组件 多级菜单 示例鼠标快速移出移入子级菜单,子级菜单不会关闭,父级菜单会关闭 #54496

Description

@chenjiandmw

Reproduction link

https://ant-design.antgroup.com/components/dropdown-cn

Steps to reproduce

2025-07-28.08-38-13.mp4

What is expected?

要么都关闭,要么都不关闭

What is actually happening?

父级菜单关闭了

Environment Info
antd 5.26.6
React 19.1.0
System Windows 11
Browser 138.0.7204.169

Activity

  1. dosubot commented on Jul 28, 2025

    @dosubot

    Hi @chenjiandmw! I'm Dosu and I’m helping the ant-design team.

    这是已知的 antd Dropdown 多级菜单行为限制,根本原因是 Dropdown 组件底层依赖 rc-dropdown 和 rc-menu,这些库通过监听鼠标移入/移出事件来控制菜单的显示和隐藏。当鼠标快速在父子菜单间移动时,父级菜单会因为 mouseleave 事件被关闭,而子菜单可能还保持打开状态,这不是 antd 的自定义逻辑,而是底层库的默认实现相关源码分析。

    目前 antd 5.26.6 没有官方配置项可以直接改变这种行为,也没有推荐的 workaround。社区常见的变通方式有:将 Dropdown 的 trigger 设置为 'click'(但会改变交互方式),或者通过受控模式手动同步父子菜单的 open 状态,但这需要自定义较多逻辑,复杂度较高相关讨论。

    如果需要更细致的交互体验,建议关注 rc-dropdown/rc-menu 的后续更新,或考虑自定义菜单的显示/隐藏逻辑。

    To reply, just mention @dosu.


    Share context across your team and agents. Try Dosu.

    Leave Feedback Learn about ant-design with Dosu Add Dosu to your team

  2. added
    🐛 BugAnt Design Team had proved that this is a bug.
    and removed on Jul 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Inactive🐛 BugAnt Design Team had proved that this is a bug.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions