Skip to content

Commit 752b44f

Browse files
authored
Merge pull request #788 from goyalpalak18/fix/selection-manager-listener-leak
2 parents 9636a4f + cb9daec commit 752b44f

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

packages/phoenix-event-display/src/managers/three-manager/selection-manager.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,11 +187,21 @@ export class SelectionManager {
187187
/**
188188
* Enable passive double-click detection (always active, independent of selection).
189189
* Sets up event listeners for both main and overlay canvases.
190+
* This method can be called multiple times safely due to listener deduplication.
190191
*/
191192
private enablePassiveDoubleClick() {
192193
// Main canvas (always available)
193194
const mainCanvas = document.getElementById('three-canvas');
194195
if (mainCanvas) {
196+
// Remove existing listeners to avoid duplicates on re-initialization
197+
mainCanvas.removeEventListener(
198+
'mousedown',
199+
this.onPassiveMouseDown,
200+
true,
201+
);
202+
mainCanvas.removeEventListener('mouseup', this.onPassiveMouseUp, true);
203+
204+
// Add listeners
195205
mainCanvas.addEventListener('mousedown', this.onPassiveMouseDown, true);
196206
mainCanvas.addEventListener('mouseup', this.onPassiveMouseUp, true);
197207
}

0 commit comments

Comments
 (0)