Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion web-src/src/common/components/AppLayout.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<div class="app-layout">
<div ref="appSidebar" :class="{collapsed: !showSidebar}" class="app-sidebar shadow-8dp"
:style="{width: sidebarWidth + 'px'}">
:style="sidebarStyle">
<slot name="sidebar"/>
</div>
<div v-show="!narrowView"
Expand Down Expand Up @@ -74,6 +74,15 @@ export default {
sidebarWidth: DEFAULT_SIDEBAR_WIDTH
}
},

computed: {
sidebarStyle() {
// The custom (resizable) width only applies to the desktop layout. In the
// narrow/overlay layout the width is set by CSS (capped to the viewport),
// so a wide desktop width doesn't overflow a phone screen.
return this.narrowView ? {} : {width: this.sidebarWidth + 'px'};
}
},
mounted() {
this.sidebarWidth = loadSidebarWidth();

Expand Down Expand Up @@ -286,6 +295,11 @@ function updatedStylesBasedOnContent(contentHeader, contentPanel, appLayout) {
height: 100vh;
z-index: 999;
transition: transform 0.3s;

/* Overlay width is viewport-driven here (the inline desktop width is not
applied in narrow view), so it never overflows a phone screen. */
width: 300px;
max-width: 85vw;
}

.app-sidebar.collapsed {
Expand Down
14 changes: 14 additions & 0 deletions web-src/tests/unit/common/AppLayout_resize_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,4 +107,18 @@ describe('Test AppLayout resizable sidebar', function () {
layout = mountLayout();
expect(layout.find('.sidebar-resizer').exists()).toBe(true);
});

it('does not apply the custom width in narrow (overlay) view', async function () {
vi.stubGlobal('localStorage', inMemoryLocalStorage({[KEY]: '600'}));
layout = mountLayout();

// Desktop: width applied inline.
expect(layout.vm.sidebarStyle).toEqual({width: '600px'});

// Narrow/overlay: width is left to CSS so it can't overflow the screen.
layout.vm.narrowView = true;
await layout.vm.$nextTick();
expect(layout.vm.sidebarStyle).toEqual({});
expect(layout.find('.app-sidebar').attributes('style') || '').not.toContain('width: 600px');
});
});
Loading