On Mon, 23 Mar 2026 15:48:21 GMT, Dmitry Markov <[email protected]> wrote:

> On macOS the menuBar with a custom menu item may disappear. For example, once 
> switching from the menu with custom item to the system menu. 
> 
> The method `rebuildUI()` in `MenuBarSkin` class clears the menu first, then 
> `menuContainsCustomMenuItem()` correctly blocks promotion to the macOS system 
> menu and prints warning. However `rebuildUI()` returns at line 917: 
> `isUseSystemMenuBar()` returns true but the menu cannot be installed into 
> system menu due to `CustomMenuItem`. As a result the menu bar disappears.
> 
> Fix:
> The `rebuildUI()` has to ensure that the menu does not contain 
> `CustomMenuItem` when switching to the system menu.
> 
> On a side note, for the working scenario described in the bug the same 
> _if-statement_ in `rebuildUI()` woks slightly different: the 
> `currentMenuBarStage` is not _NULL_ but it no longer maps to this skin as a 
> result the method does not return earlier and the menu gets rebuilt.

> Since it looks like FX is capable of handling menu updates at runtime, a 
> custom menu item in the system menu should force the menu to go back to the 
> application window. Instead, the system menu now shows an empty item:
> 
> Should we fix this scenario as well?

Unfortunately it looks like fixing this case would be a bit involved. I think 
the menu bar skin would have to add and remove change listeners to the global 
menu adapters and then rebuild the skin. And it might be tricky to rebuild the 
global menu adapters from within a change event attached to one of those 
adapters (at the very least it would take some thought). There's no indication 
that any developer has run into this problem and they can work around it by 
simply turning off the system menus so I'm inclined to let it go. In any case I 
would want to handle it as a separate bug report and PR.

-------------

PR Comment: https://git.openjdk.org/jfx/pull/2125#issuecomment-4119456989

Reply via email to