Avoid stacking image-preview document click handlers

showImagePreview bound a click.imagepreview handler without removing a
prior one. It is re-invoked during image arrow-navigation while a preview
is open, so identical document handlers accumulated until close. Remove
any existing handler before binding.
This commit is contained in:
jelveh
2026-07-16 18:43:53 -07:00
parent c851ba5543
commit 461675cb7b
+3 -2
View File
@@ -974,9 +974,10 @@ const TabFiles = {
this.previewOpen = true;
this.previewCurrentUid = uid;
// Close on click outside the popover
// Close on click outside the popover. Remove any prior handler first so
// repeated calls (image arrow-navigation) don't stack duplicate handlers.
const _this = this;
$(document).on('click.imagepreview', (e) => {
$(document).off('click.imagepreview').on('click.imagepreview', (e) => {
if ( ! $(e.target).closest('.image-preview-popover').length ) {
_this.closeImagePreview();
}