Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: handle sidebar resizing #12045

Merged
merged 1 commit into from
Dec 23, 2024
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
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
15 changes: 13 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,15 @@ export default defineComponent({
display: none;
}
}

.app-wrapper {
.app-wrapper-content {
width: 100%;
}

.app-sidebar-open .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 = () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe we can think of debouncing the function.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That might cause again "laggy" reactivity. Resize does not happen that often so I think it is fine not to have it debounced.

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