JDK-8244075 : Accelerator of ContextMenu's MenuItem is not removed when ContextMenu is removed from Scene
  • Type: Bug
  • Component: javafx
  • Sub-Component: controls
  • Affected Version: openjfx14
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2020-04-29
  • Updated: 2022-10-21
  • Resolved: 2021-06-11
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 8 Other
8u331Fixed openjfx17Fixed
Related Reports
Blocks :  
Blocks :  
Relates :  
Relates :  
Relates :  
Relates :  
Description
This was found while working on JDK-8175358 as a review comment in PR - https://github.com/openjdk/jfx/pull/199.

It can be easily reproduced by either modifying test JDK-8175358 in to use a ContextMenu or running following JunitTest (to be added in AcceleratorParameterizedTest.java)

@Test public void testAcceleratorIsNotFiredWhenMenuItemRemovedFromScene() {
        KeyEventFirer kb = new KeyEventFirer(item1, scene);

        kb.doKeyPress(KeyCode.DIGIT1, KeyModifier.ALT);
        assertEquals(1, eventCounter);

        // Remove all children from the scene
        Group root = (Group)scene.getRoot();
        root.getChildren().clear();

        kb.doKeyPress(KeyCode.DIGIT1, KeyModifier.ALT);
        assertEquals(1, eventCounter);
    }
Comments
Changeset: 0ffa8e28 Author: Ambarish Rapte <arapte@openjdk.org> Date: 2021-06-11 16:34:31 +0000 URL: https://git.openjdk.java.net/jfx/commit/0ffa8e2824d64b585363ae7a1a51890e1f5b9000
11-06-2021