Skip to content

Commit

Permalink
fix: handle sidebar resizing
Browse files Browse the repository at this point in the history
Fixed various issues with sidebar resizing. Close button is no longer pushed away, resize event is added, and correct breakpoint is used.
  • Loading branch information
LukasHirt committed Dec 18, 2024
1 parent 4f63849 commit 73cbac5
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Bugfix: Do not push sidebar close action away

We've fixed an issue with the sidebar close action which was pushed away when zooming. The layout of the screen was not adjusting the size and shifted the whole sidebar off the screen. We set a fixed width of 100% - sidebar width to prevent this.

https://github.com/owncloud/web/pull/12045
https://github.com/owncloud/web/issues/11536
5 changes: 5 additions & 0 deletions changelog/unreleased/bugfix-update-sidebar-width-on-resize.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Bugfix: Update sidebar width on resize

We've fixed an issue where the width of the sidebar was updated only when opening it. We added a resize event handler to the window object so that we can react to it and update the width accordingly.

https://github.com/owncloud/web/pull/12045
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Bugfix: Use correct breakpoints in sidebar

We've set the correct breakpoint used for setting width of the sidebar so that it matches the breakpoint in app wrapper.

https://github.com/owncloud/web/pull/12045
9 changes: 7 additions & 2 deletions packages/web-pkg/src/components/AppTemplates/AppWrapper.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<main :id="applicationId" class="oc-height-1-1" @keydown.esc="closeApp">
<main :id="applicationId" class="app-wrapper oc-height-1-1" @keydown.esc="closeApp">
<h1 class="oc-invisible-sr" v-text="pageTitle" />
<app-top-bar
v-if="!loading && !loadingError && resource"
Expand All @@ -18,7 +18,7 @@
class="oc-flex oc-width-1-1 oc-height-1-1"
:class="{ 'app-sidebar-open': isSideBarOpen }"
>
<slot class="oc-height-1-1 oc-width-1-1" v-bind="slotAttrs" />
<slot class="app-wrapper-content oc-height-1-1" v-bind="slotAttrs" />
<file-side-bar :is-open="isSideBarOpen" :active-panel="sideBarActivePanel" :space="space" />
</div>
</main>
Expand Down Expand Up @@ -710,4 +710,9 @@ export default defineComponent({
display: none;
}
}
.app-wrapper .app-wrapper-content {
// 440px is the width of the app sidebar
width: calc(100% - 440px);
}
</style>
21 changes: 19 additions & 2 deletions packages/web-pkg/src/components/SideBar/SideBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ import {
defineComponent,
nextTick,
onBeforeUnmount,
onMounted,
PropType,
ref,
unref,
Expand Down Expand Up @@ -203,11 +204,21 @@ export default defineComponent({
return $gettext('Back to main panels')
})
const fullWidthSideBar = computed(() => window.innerWidth <= 1024)
const windowWidth = ref(window.innerWidth)
const fullWidthSideBar = computed(() => unref(windowWidth) <= 960)
const backgroundContentEl = computed(() => {
return unref(appSideBar)?.parentElement?.querySelector('div') as HTMLElement
})
const onResize = () => {
if (!props.isOpen) {
return
}
windowWidth.value = window.innerWidth
}
watch(
() => props.isOpen,
async (isOpen) => {
Expand All @@ -223,7 +234,13 @@ export default defineComponent({
{ immediate: true }
)
onMounted(() => {
window.addEventListener('resize', onResize)
})
onBeforeUnmount(() => {
window.removeEventListener('resize', onResize)
if (unref(backgroundContentEl)) {
unref(backgroundContentEl).style.visibility = 'visible'
}
Expand Down Expand Up @@ -291,7 +308,7 @@ export default defineComponent({
width: 100% !important;
}
@media only screen and (max-width: 1024px) {
@media only screen and (max-width: $oc-breakpoint-medium-default) {
.files-wrapper {
flex-wrap: nowrap !important;
}
Expand Down

0 comments on commit 73cbac5

Please sign in to comment.