FIX: Error when filtering site settings

FIX: Error when filtering site settings

Happened only when none of the logo settings had an image assigned.

diff --git a/app/assets/javascripts/discourse/components/image-uploader.js.es6 b/app/assets/javascripts/discourse/components/image-uploader.js.es6
index 8ed486a..5d468b1 100644
--- a/app/assets/javascripts/discourse/components/image-uploader.js.es6
+++ b/app/assets/javascripts/discourse/components/image-uploader.js.es6
@@ -15,7 +15,10 @@ export default Ember.Component.extend(UploadMixin, {
 
   willDestroyElement() {
     this._super(...arguments);
-    $("a.lightbox").magnificPopup("close");
+    const elem = $("a.lightbox");
+    if (elem && typeof elem.magnificPopup === "function") {
+      $("a.lightbox").magnificPopup("close");
+    }
   },
 
   @computed("imageUrl")

GitHub sha: 14f9e559

2 Likes