On Wed, 11 Mar 2026 09:40:24 GMT, Jose Pereda <[email protected]> wrote:
>> This PR fixes https://bugs.openjdk.org/browse/JDK-8263959, an issue on macOS >> that happens when a menu is disabled, and then enabled back again, where >> leaf menuItems remain disabled unexpectedly, by re-syncing the native >> NSMenuItem enabled state from Java menuItem enabled state. >> >> Explanation: We create the native NSMenuItems with `autoenablesItems:YES`, >> which means the OS calls `GlassMenu::validateMenuItem:` on each item's >> target to determine if it should be enabled. This calls the Java >> `GlassSystemMenu::validate` callback, which updates the accelerator >> bindings, but it doesn't update the enabled state: It remains as it was (in >> this case, disabled when the parent menu was disabled) as >> `[glassTargetItem->item isEnabled]` returns the old state (NO/disabled) >> rather than the updated Java state (`!menuitem.isDisable()`/enabled). >> >> One possible and valid fix would be changing `autoenablesItems:YES` to >> `autoenablesItems:NO`, as the Java layer already manages the enable state >> via `GlassMenu::_setEnabled` (making `validateMenuItem:` redundant for this >> case). >> >> However, the proposed fix doesn't change that, and simply syncs the native >> side with the Java side while validation is being performed. >> >> A system test has been included, if fails before this patch, passes after it. > > Jose Pereda has updated the pull request incrementally with one additional > commit since the last revision: > > Address feedback from reviewer tests/system/src/test/java/test/robot/javafx/scene/SystemMenuBarEnableTest.java line 143: > 141: }); > 142: Util.sleep(2 * DELAY); > 143: } optional: I would recommend to add another **Util.runAndWait** block here to close the menu. and remove the calls `robotMenu(false, false, false);` // hide menu Util.runAndWait(() -> { Robot robot = new Robot(); robot.keyType(KeyCode.ESCAPE); }); I had this comment earlier batch, it wasn't posted. not sure why. tests/system/src/test/java/test/robot/javafx/scene/SystemMenuBarEnableTest.java line 148: > 146: public static class TestApp extends Application { > 147: > 148: private Menu menu; With the other variable, even the variable `menu` could move to outer class. and we can remove the variable `testApp` ------------- PR Review Comment: https://git.openjdk.org/jfx/pull/2103#discussion_r2918604251 PR Review Comment: https://git.openjdk.org/jfx/pull/2103#discussion_r2918600036
