Skip to content

A platform for community discussion. Free, open, simple.

FIX: Add check for if element doesnt exist on ensureDropClosed (#13256)

Jordan Vidrine188ac1c51fee
diff --git a/app/assets/javascripts/discourse/app/components/navigation-bar.js b/app/assets/javascripts/discourse/app/components/navigation-bar.js
index 5c354a80f5b..546841c8a5e 100644
--- a/app/assets/javascripts/discourse/app/components/navigation-bar.js
+++ b/app/assets/javascripts/discourse/app/components/navigation-bar.js
@@ -52,6 +52,10 @@ export default Component.extend(FilterModeMixin, {
},
ensureDropClosed() {
+ if (!this.element || this.isDestroying || this.isDestroyed) {
+ return;
+ }
+
if (this.expanded) {
this.set("expanded", false);
}
@@ -75,17 +79,13 @@ export default Component.extend(FilterModeMixin, {
this.element.querySelector(".drop").style.display = "none";
next(() => {
- if (!this.element || this.isDestroying || this.isDestroyed) {
- return;
- }
- this.set("expanded", false);
+ this.ensureDropClosed();
});
-
return true;
});
$(window).on("click.navigation-bar", () => {
- this.set("expanded", false);
+ this.ensureDropClosed();
return true;
});
});