Skip to content

Commit

Permalink
Fix sidebars resetting their active state on window resize
Browse files Browse the repository at this point in the history
  • Loading branch information
oxixes committed Jun 17, 2024
1 parent b073a2b commit 3ae1941
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
2 changes: 2 additions & 0 deletions src/wirecloud/commons/middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,8 @@ class LocaleMiddleware(MiddlewareMixin):
def process_request(self, request):
if 'lang' in request.GET and translation.check_for_language(request.GET['lang']):
language = request.GET['lang']
elif 'lang' in request.COOKIES and translation.check_for_language(request.COOKIES['lang']):
language = request.COOKIES['lang']
else:
language = translation.get_language_from_request(request, check_path=False)
translation.activate(language)
Expand Down
11 changes: 8 additions & 3 deletions src/wirecloud/platform/static/js/wirecloud/ui/SidebarLayout.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@

constructor(dragboard, options) {
options = utils.merge({
position: "left"
position: "left",
active: false
}, options);

if (POSITIONS.indexOf(options.position) === -1) {
Expand All @@ -97,7 +98,7 @@
);

privates.set(this, {
active: false
active: options.active
});

Object.defineProperties(this, {
Expand All @@ -115,7 +116,7 @@

this.handle = document.createElement("div");
this.handleicon = document.createElement("i");
this.handleicon.className = "fas fa-caret-" + OPPOSITE[this.position];
this.handleicon.className = "fas fa-caret-" + (this.active ? ICON[this.position] : OPPOSITE[this.position]);
this.handle.appendChild(this.handleicon);
this.handle.addEventListener("click", () => {
this.active = !this.active;
Expand Down Expand Up @@ -245,6 +246,10 @@
}
}

isActive() {
return this.active;
}

}

})(Wirecloud.ui, Wirecloud.Utils);
Original file line number Diff line number Diff line change
Expand Up @@ -217,10 +217,10 @@
this.fulldragboardLayout = new Wirecloud.ui.FullDragboardLayout(this);
this.baseLayout = this._buildLayoutFromPreferences();
this.freeLayout = new Wirecloud.ui.FreeLayout(this);
this.leftLayout = new Wirecloud.ui.SidebarLayout(this);
this.rightLayout = new Wirecloud.ui.SidebarLayout(this, {position: "right"});
this.bottomLayout = new Wirecloud.ui.SidebarLayout(this, {position: "bottom"});
this.topLayout = new Wirecloud.ui.SidebarLayout(this, {position: "top"});
this.leftLayout = new Wirecloud.ui.SidebarLayout(this, {active: (this.leftLayout) ? this.leftLayout.isActive() : false});
this.rightLayout = new Wirecloud.ui.SidebarLayout(this, {position: "right", active: (this.rightLayout) ? this.rightLayout.isActive() : false});
this.bottomLayout = new Wirecloud.ui.SidebarLayout(this, {position: "bottom", active: (this.bottomLayout) ? this.bottomLayout.isActive() : false});
this.topLayout = new Wirecloud.ui.SidebarLayout(this, {position: "top", active: (this.topLayout) ? this.topLayout.isActive() : false});
}

updateWidgetScreenSize(screenSize) {
Expand Down

0 comments on commit 3ae1941

Please sign in to comment.