Add early return for movingDivs click handler

53dc8702c35976170d0dbef03a0caa0ce4d6fdf1

Cohee <18619528+Cohee1207@users.noreply.github.com>

1 files changed, +4 -2Showing whitespace changes
public/scripts/extensions/gallery/index.js+4 -2
@@ -26,9 +26,11 @@ let paginationVisiblePages = 10;
2626let paginationMaxLinesPerPage = 2;
2727let galleryMaxRows = 3;
2828
29+// Remove all draggables associated with the gallery
2930$('#movingDivs').on('click', '.dragClose', function () {
3031 const relatedId = $(this).data('related-id'); // Get the ID of the related draggable
31- $(`#movingDivs > .draggable[id="${relatedId}"]`).remove(); // Remove the associated draggable
32+ if (!relatedId) return;
33+ $(`#movingDivs > .draggable[id="${relatedId}"]`).remove();
3234});
3335
3436const CUSTOM_GALLERY_REMOVED_EVENT = 'galleryRemoved';