Detailed steps on how to reproduce the bug
When a MenuBarComponent has empty top-level menus, dismissing the menus by clicking elsewhere in the app window doesn't work. Even though non-empty menus will be closed, there still remains a highlight for the last selected menu which will only go away when clicking into the empty area of the menu bar.
Found the cause by debugging/blaming:
Some logic was added to MenuBarComponent in 2024 to count the numActiveMenus up and down in order to decide whether to unselect the selected menu. This counter will miscount if the menu bar has empty menus, because the counter is incremented unconditionally, without considering that the menu window might not even be created (so the dismissal callback won't be called, and so the counter won't be decremented).
As a quick solution, the code in MenuBarComponent could just check if the PopupMenu is empty and not increment if it is. The cleaner solution would properly be something like a return value for PopupMenu::showMenuAsync that indicates whether or not something was actually shown, or calling the callback anyway even if nothing was shown due to the lack of entries.
What is the expected behaviour?
When I select an entry from the application menu,
and, in order to dismiss the menu, I click somewhere else in my app window,
Then I always want the menu to be dismissed / unselected.
Operating systems
macOS
What versions of the operating systems?
OS-independent bug, also happens on Windows.
Architectures
Arm64/aarch64
Stacktrace
OS/architecture independent
Plug-in formats (if applicable)
No response
Plug-in host applications (DAWs) (if applicable)
No response
Testing on the develop branch
I have not tested against the develop branch
Code of Conduct
Detailed steps on how to reproduce the bug
When a MenuBarComponent has empty top-level menus, dismissing the menus by clicking elsewhere in the app window doesn't work. Even though non-empty menus will be closed, there still remains a highlight for the last selected menu which will only go away when clicking into the empty area of the menu bar.
Found the cause by debugging/blaming:
Some logic was added to
MenuBarComponentin 2024 to count thenumActiveMenusup and down in order to decide whether to unselect the selected menu. This counter will miscount if the menu bar has empty menus, because the counter is incremented unconditionally, without considering that the menu window might not even be created (so the dismissal callback won't be called, and so the counter won't be decremented).As a quick solution, the code in MenuBarComponent could just check if the PopupMenu is empty and not increment if it is. The cleaner solution would properly be something like a return value for
PopupMenu::showMenuAsyncthat indicates whether or not something was actually shown, or calling the callback anyway even if nothing was shown due to the lack of entries.What is the expected behaviour?
When I select an entry from the application menu,
and, in order to dismiss the menu, I click somewhere else in my app window,
Then I always want the menu to be dismissed / unselected.
Operating systems
macOS
What versions of the operating systems?
OS-independent bug, also happens on Windows.
Architectures
Arm64/aarch64
Stacktrace
Plug-in formats (if applicable)
No response
Plug-in host applications (DAWs) (if applicable)
No response
Testing on the
developbranchI have not tested against the
developbranchCode of Conduct