1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2025-01-04 05:56:02 +00:00

fix: close context menu with a click outside listener

This commit is contained in:
Rukario 2024-12-25 11:09:24 -08:00 committed by GitHub
parent c3b48882b8
commit 698b4348a0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -3,7 +3,7 @@
or any future license endorsed by Mnemosyne LLC.
License text can be found in the licenses/ folder. */
import { setEnabled } from './utils.js';
import { OutsideClickListener, setEnabled } from './utils.js';
export class ContextMenu extends EventTarget {
constructor(action_manager) {
@ -14,6 +14,10 @@ export class ContextMenu extends EventTarget {
this.action_manager.addEventListener('change', this.action_listener);
Object.assign(this, this._create());
this.outside = new OutsideClickListener(this.root);
this.outside.addEventListener('click', () => this.close());
this.show();
}
@ -26,6 +30,7 @@ export class ContextMenu extends EventTarget {
close() {
if (!this.closed) {
this.outside.stop();
this.action_manager.removeEventListener('change', this.action_listener);
this.root.remove();
this.dispatchEvent(new Event('close'));