From 10b5c11280e9b3657383bd1fe93363db0e9146b5 Mon Sep 17 00:00:00 2001 From: Michael Kauzmann Date: Wed, 28 Aug 2024 19:22:42 -0600 Subject: [PATCH] better dispose (bug fix), https://github.com/phetsims/density-buoyancy-common/issues/364 Signed-off-by: Michael Kauzmann --- js/accessibility/GrabDragInteraction.ts | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/js/accessibility/GrabDragInteraction.ts b/js/accessibility/GrabDragInteraction.ts index 107ac2a0..4f57a743 100644 --- a/js/accessibility/GrabDragInteraction.ts +++ b/js/accessibility/GrabDragInteraction.ts @@ -663,15 +663,8 @@ export default class GrabDragInteraction extends EnabledComponent { } } - if ( voicingNode.interactiveHighlightLayerable ) { - const highlightParent = this.grabInteractiveHighlight.parent!; - assert && assert( highlightParent, 'how can we have interactiveHighlightLayerable with a ' + - 'node that is not in the scene graph?' ); - - if ( highlightParent.hasChild( this.dragInteractiveHighlight ) ) { - highlightParent.removeChild( this.dragInteractiveHighlight ); - } - } + // to support cases of interactiveHighlightLayerable + this.dragInteractiveHighlight.detach(); releasedUtterance.dispose(); this.voicingFocusUtterance.dispose(); @@ -680,7 +673,7 @@ export default class GrabDragInteraction extends EnabledComponent { this.ownsGrabFocusHighlight && this.grabFocusHighlight.dispose(); this.ownsGrabInteractiveHighlight && this.grabInteractiveHighlight.dispose(); this.grabCueNode.dispose(); - this.dragCueNode && ( this.dragFocusHighlight.focusHighlight as HighlightPath ).removeChild( this.dragCueNode ); + this.dragCueNode && this.dragCueNode.detach(); }; }