On Wed, 11 Mar 2026 00:46:22 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. ## Pull request overview This PR fixes JDK-8263959 on macOS where leaf system menu items can remain disabled after a parent menu is disabled and then re-enabled, by re-syncing native `NSMenuItem` enabled state from the Java `MenuItem` state during validation. **Changes:** - Sync native `MenuItem` enabled state from Java `MenuItemBase.isDisable()` during the validate callback. - Add a macOS-only robot system test to reproduce and guard against the regression. ### Reviewed changes Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments. | File | Description | | ---- | ----------- | | `tests/system/src/test/java/test/robot/javafx/scene/SystemMenuBarEnableTest.java` | Adds a system-level regression test exercising disable/re-enable behavior for system menu bar items on macOS. | | `modules/javafx.graphics/src/main/java/com/sun/javafx/tk/quantum/GlassSystemMenu.java` | Ensures native menu item enabled state is refreshed from Java state inside the validation callback. | --- 💡 <a href="/openjdk/jfx/new/master?filename=.github/instructions/*.instructions.md" class="Link--inTextBlock" target="_blank" rel="noopener noreferrer">Add Copilot custom instructions</a> for smarter, more guided reviews. <a href="https://docs.github.com/en/copilot/customizing-copilot/adding-repository-custom-instructions-for-github-copilot" class="Link--inTextBlock" target="_blank" rel="noopener noreferrer">Learn how to get started</a>. ------------- PR Review: https://git.openjdk.org/jfx/pull/2103#pullrequestreview-3926263617
