Skip to content

Commit

Permalink
Fix menu disposal (#180)
Browse files Browse the repository at this point in the history
  • Loading branch information
lovemegowin authored Jun 26, 2024
1 parent d48f868 commit 3cfcb4b
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -373,21 +373,14 @@ export default function contextMenu(options = {}) {

const disposeMenu = create(win, options);

disposables.push(disposeMenu);
const removeDisposable = () => {
const index = disposables.indexOf(disposeMenu);
if (index !== -1) {
disposables.splice(index, 1);
}
const disposable = () => {
win.off('close', disposable);
disposeMenu();
};

if (win.once !== undefined) { // Support for BrowserView
win.once('closed', removeDisposable);
win.once('close', disposable);
}

disposables.push(() => {
win.off('closed', removeDisposable);
});
};

const dispose = () => {
Expand Down

0 comments on commit 3cfcb4b

Please sign in to comment.