Skip to content

Commit ff48a11

Browse files
Lightning00BladeDevtools-frontend LUCI CQ
authored andcommitted
Cleanup GlassPane on Widget detach
The event listener were still there if you show the GlassPane and then detach the Widget. This cause the last Tree closure https://ci.chromium.org/ui/p/devtools-frontend/builders/ci/Stand-alone%20Linux/22115/overview Bug: none Change-Id: Ifd938ac51b79e4af6710547429f2dd21e0bd1a8b No-Tree-Checks: True Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/6955970 Commit-Queue: Nikolay Vitkov <[email protected]> Commit-Queue: Ergün Erdoğmuş <[email protected]> Auto-Submit: Nikolay Vitkov <[email protected]> Reviewed-by: Ergün Erdoğmuş <[email protected]>
1 parent 04c73fa commit ff48a11

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

front_end/ui/legacy/GlassPane.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ export class GlassPane {
2828
constructor(jslog?: string) {
2929
this.#widget = new Widget({jslog, useShadowDom: true});
3030
this.#widget.markAsRoot();
31+
this.#widget.onDetach = this.#onDetach.bind(this);
3132
this.element = this.#widget.element;
3233
this.contentElement = this.#widget.contentElement;
3334

@@ -124,15 +125,18 @@ export class GlassPane {
124125
if (!this.isShowing()) {
125126
return;
126127
}
127-
panes.delete(this);
128-
this.element.ownerDocument.body.removeEventListener('mousedown', this.onMouseDownBound, true);
129-
this.element.ownerDocument.body.removeEventListener('pointerdown', this.onMouseDownBound, true);
130128
this.#widget.detach();
131129
if (this.#onHideCallback) {
132130
this.#onHideCallback();
133131
}
134132
}
135133

134+
#onDetach(): void {
135+
panes.delete(this);
136+
this.element.ownerDocument.body.removeEventListener('mousedown', this.onMouseDownBound, true);
137+
this.element.ownerDocument.body.removeEventListener('pointerdown', this.onMouseDownBound, true);
138+
}
139+
136140
private onMouseDown(event: Event): void {
137141
if (!this.onClickOutsideCallback) {
138142
return;

0 commit comments

Comments
 (0)