fix: stop leaking a document keydown handler per uninstall-modal dismissal

showUninstallModal bound `keydown.uninstall-modal` on document but only
detached it on the Escape and Confirm paths. Dismissing via Cancel or a
backdrop click called `close()`, which just removed the overlay and left the
handler attached (closing over a now-detached overlay). Each open→cancel
cycle stacked another document-level listener for the page lifetime.

Move the `.off('keydown.uninstall-modal')` into `close()` so every dismissal
path cleans up, and drop the now-redundant explicit detaches.
This commit is contained in:
jelveh
2026-07-16 19:50:37 -07:00
parent 6549072727
commit a700d9e648
+5 -6
View File
@@ -129,17 +129,17 @@ function showUninstallModal ({ appName, appTitle, appUid, self, $el_window }) {
$el_window.append($overlay);
const close = () => $overlay.remove();
const close = () => {
$overlay.remove();
$(document).off('keydown.uninstall-modal');
};
$overlay.on('click', '.myapps-modal-cancel', close);
$overlay.on('click', function (e) {
if ( e.target === $overlay[0] ) close();
});
$(document).on('keydown.uninstall-modal', function (e) {
if ( e.key === 'Escape' ) {
close();
$(document).off('keydown.uninstall-modal');
}
if ( e.key === 'Escape' ) close();
});
$overlay.on('click', '.myapps-modal-confirm', async function () {
@@ -154,7 +154,6 @@ function showUninstallModal ({ appName, appTitle, appUid, self, $el_window }) {
console.error('Failed to uninstall app:', err);
}
close();
$(document).off('keydown.uninstall-modal');
});
}