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.

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.