Skip to content

Menu - Submenu remains visible even after closing the parent menu #43267

Closed
react-component/menu
#893

Description

@SpaNb4

Reproduction link

Edit on CodeSandbox

Steps to reproduce

  1. Click on the "Click me" button to open the dropdown menu
  2. Click on the "Submenu" item
  3. Press the Esc key to close the parent menu

What is expected?

Submenu is closed

What is actually happening?

Submenu remains visible

Environment Info
antd 5.6.3
React 18.2.0
System Pop!_OS 22.04 LTS
Browser Version 114.0.5735.198

Activity

  1. added
    🐛 BugAnt Design Team had proved that this is a bug.
    and removed on Jun 29, 2023
  2. MadCcc commented on Jun 29, 2023

    @MadCcc
    Member

    Should focus submenu when opened.

  3. self-assigned this
    on Jul 3, 2023
  4. heiyu4585 commented on Jul 7, 2023

    @heiyu4585
    Contributor

    结论: Menu 自己维护的 active,这个有点难改的


    1. subMenu子菜单hover的时候触发一次 onAcitve,当前的aciveKey 就是 当前的hover子菜单 1-2
    2. 键盘事件->useAccessibility -> 会触发到offsetObj.offset < 0 触发一次关闭父级菜单的操作 triggerAccessibilityOpen]
  5. removed their assignment
    on Jul 7, 2023
  6. tomislavdimitrov2003 commented on Aug 1, 2023

    @tomislavdimitrov2003

    Issues is still present. Will there be a fix for it soon?

  7. yoyo837 commented on Dec 5, 2023

    @yoyo837
    Contributor
  8. SpaNb4 commented on Dec 6, 2023

    @SpaNb4
    ContributorAuthor
  9. yoyo837 commented on Dec 9, 2023

    @yoyo837
    Contributor

    It looks like the issue is related to triggerSubMenuAction="click".

  10. noxxxxxxxx commented on Apr 29, 2024

    @noxxxxxxxx

    Still exist in the latest version
    image
    codesandbox

  11. EmilyyyLiu commented on Aug 27, 2026

    @EmilyyyLiu
    Contributor

    Reproduction result

    I followed the reproduction steps from this issue and can no longer reproduce the originally described behavior
    ("submenu remains visible"):

    • Open the dropdown → open the submenu → press Esc, both the dropdown and the submenu popup close correctly.

    A related behavior still observed (would like to confirm if expected)

    After opening both the dropdown and the submenu, when focus stays on the parent popup (the dropdown menu itself)
    and Esc is pressed:

    • the parent popup closes;
    • but the submenu popup does not close along with it and remains visible on screen.

    When focus is inside the submenu (on a submenu item) and Esc is pressed, both layers close as expected.

    Could you confirm whether this behavior — "focus on parent + Esc does not close the submenu, leaving it visible" —
    is expected, or whether it should also be fixed?

  12. SpaNb4 commented on Aug 28, 2026

    @SpaNb4
    ContributorAuthor

    Reproduction result

    I followed the reproduction steps from this issue and can no longer reproduce the originally described behavior ("submenu remains visible"):

    • Open the dropdown → open the submenu → press Esc, both the dropdown and the submenu popup close correctly.

    A related behavior still observed (would like to confirm if expected)

    After opening both the dropdown and the submenu, when focus stays on the parent popup (the dropdown menu itself) and Esc is pressed:

    • the parent popup closes;
    • but the submenu popup does not close along with it and remains visible on screen.

    When focus is inside the submenu (on a submenu item) and Esc is pressed, both layers close as expected.

    Could you confirm whether this behavior — "focus on parent + Esc does not close the submenu, leaving it visible" — is expected, or whether it should also be fixed?

    Thanks for revalidating! Can confirm the original issue no longer reproduces on the latest antd version.

    However, I found another related issue: open the dropdown menu → open the submenu → press Tab twice (or once if focus is on the submenu). The parent popup closes but the submenu stays visible. Video attached: video
    Sandbox to reproduce: https://codesandbox.io/p/devbox/antd-reproduction-template-forked-8hdkf3

    I also tried to reproduce the issue you described, but couldn't figure out how to keep focus on the parent popup while the submenu is open. Either way, that behavior does seem like a bug too.

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