mirror of
https://github.com/google/blockly.git
synced 2026-01-06 16:40:07 +01:00
fix: release dummy wheel listener on workspace dispose (#7693)
fix #7674
This commit is contained in:
@@ -247,6 +247,12 @@ export class WorkspaceSvg extends Workspace implements IASTNodeLocationSvg {
|
||||
| ((menuOptions: ContextMenuOption[], e: Event) => void)
|
||||
| null = null;
|
||||
|
||||
/**
|
||||
* A dummy wheel event listener used as a workaround for a Safari scrolling issue.
|
||||
* Set in createDom and used for removal in dispose to ensure proper cleanup.
|
||||
*/
|
||||
private dummyWheelListener: (() => void) | null = null;
|
||||
|
||||
/**
|
||||
* In a flyout, the target workspace where blocks should be placed after a
|
||||
* drag. Otherwise null.
|
||||
@@ -787,7 +793,8 @@ export class WorkspaceSvg extends Workspace implements IASTNodeLocationSvg {
|
||||
// This no-op works around https://bugs.webkit.org/show_bug.cgi?id=226683,
|
||||
// which otherwise prevents zoom/scroll events from being observed in
|
||||
// Safari. Once that bug is fixed it should be removed.
|
||||
document.body.addEventListener('wheel', function () {});
|
||||
this.dummyWheelListener = () => {};
|
||||
document.body.addEventListener('wheel', this.dummyWheelListener);
|
||||
browserEvents.conditionalBind(
|
||||
this.svgGroup_,
|
||||
'wheel',
|
||||
@@ -896,6 +903,12 @@ export class WorkspaceSvg extends Workspace implements IASTNodeLocationSvg {
|
||||
browserEvents.unbind(this.resizeHandlerWrapper);
|
||||
this.resizeHandlerWrapper = null;
|
||||
}
|
||||
|
||||
// Remove the dummy wheel listener
|
||||
if (this.dummyWheelListener) {
|
||||
document.body.removeEventListener('wheel', this.dummyWheelListener);
|
||||
this.dummyWheelListener = null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user