mirror of
https://github.com/discourse/discourse-subscriptions.git
synced 2025-02-16 08:24:44 +00:00
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 { inject as service } from "@ember/service";
|
||||
|
||||
const SIDEBAR_BODY_CLASS = "subscription-campaign-sidebar";
|
||||
|
||||
export default Component.extend({
|
||||
router: service(),
|
||||
dismissed: false,
|
||||
@ -68,9 +70,9 @@ export default Component.extend({
|
||||
didInsertElement() {
|
||||
this._super(...arguments);
|
||||
if (this.isSidebar && this.shouldShow && !this.site.mobileView) {
|
||||
document.body.classList.add("subscription-campaign-sidebar");
|
||||
document.body.classList.add(SIDEBAR_BODY_CLASS);
|
||||
} 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
|
||||
@ -93,6 +95,10 @@ export default Component.extend({
|
||||
}
|
||||
},
|
||||
|
||||
willDestroyElement() {
|
||||
document.body.classList.remove(SIDEBAR_BODY_CLASS);
|
||||
},
|
||||
|
||||
@discourseComputed("backgroundImageUrl")
|
||||
bannerInfoStyle(backgroundImageUrl) {
|
||||
if (!backgroundImageUrl) {
|
||||
@ -139,7 +145,7 @@ export default Component.extend({
|
||||
@observes("dismissed")
|
||||
_updateBodyClasses() {
|
||||
if (this.dismissed) {
|
||||
document.body.classList.remove("subscription-campaign-sidebar");
|
||||
document.body.classList.remove(SIDEBAR_BODY_CLASS);
|
||||
}
|
||||
},
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user