mirror of
https://github.com/transmission/transmission.git
synced 2025-12-20 02:18:42 +00:00
fix: close context menu with a click outside listener
This commit is contained in:
@@ -3,7 +3,7 @@
|
|||||||
or any future license endorsed by Mnemosyne LLC.
|
or any future license endorsed by Mnemosyne LLC.
|
||||||
License text can be found in the licenses/ folder. */
|
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 {
|
export class ContextMenu extends EventTarget {
|
||||||
constructor(action_manager) {
|
constructor(action_manager) {
|
||||||
@@ -14,6 +14,10 @@ export class ContextMenu extends EventTarget {
|
|||||||
this.action_manager.addEventListener('change', this.action_listener);
|
this.action_manager.addEventListener('change', this.action_listener);
|
||||||
|
|
||||||
Object.assign(this, this._create());
|
Object.assign(this, this._create());
|
||||||
|
|
||||||
|
this.outside = new OutsideClickListener(this.root);
|
||||||
|
this.outside.addEventListener('click', () => this.close());
|
||||||
|
|
||||||
this.show();
|
this.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -26,6 +30,7 @@ export class ContextMenu extends EventTarget {
|
|||||||
|
|
||||||
close() {
|
close() {
|
||||||
if (!this.closed) {
|
if (!this.closed) {
|
||||||
|
this.outside.stop();
|
||||||
this.action_manager.removeEventListener('change', this.action_listener);
|
this.action_manager.removeEventListener('change', this.action_listener);
|
||||||
this.root.remove();
|
this.root.remove();
|
||||||
this.dispatchEvent(new Event('close'));
|
this.dispatchEvent(new Event('close'));
|
||||||
|
|||||||
Reference in New Issue
Block a user