Skip to content

Bug - MenuItem - error in flyout handling #11802

@KevinFCormier

Description

@KevinFCormier

Describe the problem
There is a subtle bug in the flyout menu implementation that can crash consumers of the menu component. The problem occurs when focus is switched to a different tab or application while a flyout menu is open.

How do you reproduce the problem?
See video for PF6, using the demo: https://www.patternfly.org/components/menus/custom-menus/#flyout-menu
https://github.com/user-attachments/assets/bf6abbd9-b5d1-48d8-bb73-c18973653430

See video for PF5, using the demo: https://v5-archive.patternfly.org/components/menus/custom-menus#flyout-menu
https://github.com/user-attachments/assets/ed1f9607-5350-4b14-ac22-3dc3dc6abb90

Expected behavior
No crash

Is this issue blocking you?
No. Edge case, but it would be nice if the fix can be backported to PF 5.

Any other information?

The problem originates on line 233 of MenuItem.tsx. In this scenario, the target of the event is the text in the menu item, rather than the button itself, and that gets save to the flyout target.

Then, at line 212 of MenuItem.tsx, the next sibling is span that contains the toggle icon, rather than the div that will contain the ul element for the flyout.

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    Status

    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions