Skip to content

Commit

Permalink
Change collapsed sidebar state computation
Browse files Browse the repository at this point in the history
Fixes a bug where the collapsed value was being computed serverside and
causing the sidebar to be expanded by default on mobile.

Related to Issue #44
  • Loading branch information
BobChao87 committed Dec 29, 2021
1 parent cfc1790 commit ad86b43
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions pages/marathon/_marathon.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ export default Vue.extend({
data() {
return {
marathonId: this.$route.params.marathon,
// Show the sidebar by default on desktop-class devices
collapsed: (globalThis.innerWidth ?? 1024) < 1024,
collapsed: false,
};
},
Expand All @@ -42,6 +41,11 @@ export default Vue.extend({
},
},
mounted(): void {
// Show the sidebar by default on desktop-class devices
this.collapsed = (globalThis.innerWidth ?? 1024) < 1024;
},
watch: {
$route(to, from): void {
// Detect when the path changes (not anchors in the same page or queries)
Expand Down

0 comments on commit ad86b43

Please sign in to comment.