FIX: Ensure sidebar class is removed when component destroyed (#111)
This commit is contained in:
parent
46e0a2aa46
commit
fa490337ef
|
@ -7,6 +7,8 @@ import discourseComputed, { observes } from "discourse-common/utils/decorators";
|
||||||
import { later } from "@ember/runloop";
|
import { later } from "@ember/runloop";
|
||||||
import { inject as service } from "@ember/service";
|
import { inject as service } from "@ember/service";
|
||||||
|
|
||||||
|
const SIDEBAR_BODY_CLASS = "subscription-campaign-sidebar";
|
||||||
|
|
||||||
export default Component.extend({
|
export default Component.extend({
|
||||||
router: service(),
|
router: service(),
|
||||||
dismissed: false,
|
dismissed: false,
|
||||||
|
@ -68,9 +70,9 @@ export default Component.extend({
|
||||||
didInsertElement() {
|
didInsertElement() {
|
||||||
this._super(...arguments);
|
this._super(...arguments);
|
||||||
if (this.isSidebar && this.shouldShow && !this.site.mobileView) {
|
if (this.isSidebar && this.shouldShow && !this.site.mobileView) {
|
||||||
document.body.classList.add("subscription-campaign-sidebar");
|
document.body.classList.add(SIDEBAR_BODY_CLASS);
|
||||||
} else {
|
} else {
|
||||||
document.body.classList.remove("subscription-campaign-sidebar");
|
document.body.classList.remove(SIDEBAR_BODY_CLASS);
|
||||||
}
|
}
|
||||||
|
|
||||||
// makes sure to only play animation once, & not repeat on reload
|
// makes sure to only play animation once, & not repeat on reload
|
||||||
|
@ -93,6 +95,10 @@ export default Component.extend({
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
willDestroyElement() {
|
||||||
|
document.body.classList.remove(SIDEBAR_BODY_CLASS);
|
||||||
|
},
|
||||||
|
|
||||||
@discourseComputed("backgroundImageUrl")
|
@discourseComputed("backgroundImageUrl")
|
||||||
bannerInfoStyle(backgroundImageUrl) {
|
bannerInfoStyle(backgroundImageUrl) {
|
||||||
if (!backgroundImageUrl) {
|
if (!backgroundImageUrl) {
|
||||||
|
@ -139,7 +145,7 @@ export default Component.extend({
|
||||||
@observes("dismissed")
|
@observes("dismissed")
|
||||||
_updateBodyClasses() {
|
_updateBodyClasses() {
|
||||||
if (this.dismissed) {
|
if (this.dismissed) {
|
||||||
document.body.classList.remove("subscription-campaign-sidebar");
|
document.body.classList.remove(SIDEBAR_BODY_CLASS);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue