Skip to content

Fix Menu event listeners and touch memory leak on dispose - #43253

Open
ShakilUrRehman21 wants to merge 1 commit into
twbs:mainfrom
ShakilUrRehman21:fix/menu-dispose-listener-leak
Open

ShakilUrRehman21 wants to merge 1 commit into
twbs:mainfrom
ShakilUrRehman21:fix/menu-dispose-listener-leak

Conversation

@ShakilUrRehman21

Copy link
Copy Markdown
Contributor

Description

This PR fixes memory leaks in the Menu component when dispose() is called:

  1. Submenu event listeners on this._menu: In _setupSubmenuListeners(), event listeners (mouseenter, mouseleave, mousemove, click) were registered without namespacing. dispose() did not remove listeners on this._menu.
  2. Touch listeners on document.body.children: If disposed while open on a touch device, mouseover listeners on document.body.children were never removed.

Changes

  • Namespace submenu listeners on this._menu with EVENT_KEY.
  • In dispose(), call EventHandler.off(this._menu, EVENT_KEY).
  • In dispose(), remove touch mouseover listeners from document.body.children.
  • Add unit tests verifying dispose() removes listeners from _menu and cleans up touch listeners.

@ShakilUrRehman21
ShakilUrRehman21 requested a review from a team as a code owner October 31, 2026 12:31
@julien-deramond julien-deramond added v6 v6, the main branch bug Something does not work as documented js JavaScript or TypeScript sources and plugins labels Oct 31, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something does not work as documented js JavaScript or TypeScript sources and plugins v6 v6, the main branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants