FIX: prevents mobile nav to create an error when unregistering click events (#8016)
This what happening when clickin on "All groups", as it was trying to get element of a destroying component.
This commit is contained in:
parent
47638ffea4
commit
1a731dcff1
|
@ -4,7 +4,7 @@ export default Ember.Component.extend({
|
||||||
@on("init")
|
@on("init")
|
||||||
_init() {
|
_init() {
|
||||||
if (!this.get("site.mobileView")) {
|
if (!this.get("site.mobileView")) {
|
||||||
var classes = this.desktopClass;
|
let classes = this.desktopClass;
|
||||||
if (classes) {
|
if (classes) {
|
||||||
classes = classes.split(" ");
|
classes = classes.split(" ");
|
||||||
this.set("classNames", classes);
|
this.set("classNames", classes);
|
||||||
|
@ -31,6 +31,8 @@ export default Ember.Component.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
didInsertElement() {
|
didInsertElement() {
|
||||||
|
this._super(...arguments);
|
||||||
|
|
||||||
this._updateSelectedHtml();
|
this._updateSelectedHtml();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -43,9 +45,12 @@ export default Ember.Component.extend({
|
||||||
$(window)
|
$(window)
|
||||||
.off("click.mobile-nav")
|
.off("click.mobile-nav")
|
||||||
.on("click.mobile-nav", e => {
|
.on("click.mobile-nav", e => {
|
||||||
let expander = $(this.element.querySelector(".expander"));
|
if (!this.element || this.isDestroying || this.isDestroyed) {
|
||||||
expander = expander && expander[0];
|
return;
|
||||||
if ($(e.target)[0] !== expander) {
|
}
|
||||||
|
|
||||||
|
const expander = this.element.querySelector(".expander");
|
||||||
|
if (expander && e.target !== expander) {
|
||||||
this.set("expanded", false);
|
this.set("expanded", false);
|
||||||
$(window).off("click.mobile-nav");
|
$(window).off("click.mobile-nav");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue