Skip to content

Commit 5a4f729

Browse files
refactor(client): reposition dockingPanel dropdown on window resize (#497)
1 parent 88976d5 commit 5a4f729

File tree

1 file changed

+8
-15
lines changed

1 file changed

+8
-15
lines changed

packages/client/src/components/common/SideNav.vue

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ const sidebarScrollable = computed(() => devtoolsClientState.value.scrollableSid
1212
const { enabledTabs, flattenedTabs } = useAllTabs()
1313
1414
const ITEM_HEIGHT = 45
15-
const INIT_DISTANCE = 6
16-
const DIF_DISTANCE = 200
1715
1816
const { height: windowHeight } = useWindowSize()
1917
const containerCapacity = computed(() => {
@@ -44,31 +42,26 @@ onClickOutside(
4442
{ detectIframe: true },
4543
)
4644
47-
const distance = ref(INIT_DISTANCE)
45+
const containerRef = ref<HTMLDivElement>()
4846
49-
watch(
50-
() => devtoolsClientState.value.expandSidebar,
51-
(expandSidebar) => {
52-
if (expandSidebar) {
53-
distance.value = DIF_DISTANCE + INIT_DISTANCE
54-
}
55-
else {
56-
distance.value = INIT_DISTANCE - DIF_DISTANCE
57-
}
58-
},
47+
const dropdownDistance = ref(6)
5948
60-
)
49+
useResizeObserver(containerRef, () => {
50+
// This is a hack to force the dropdown to reposition itself
51+
dropdownDistance.value = dropdownDistance.value === 6 ? 6.01 : 6
52+
})
6153
</script>
6254

6355
<template>
6456
<div
57+
ref="containerRef"
6558
border="r base" flex="~ col items-start"
6659
class="$ui-z-max-override" h-full of-hidden bg-base
6760
>
6861
<div
6962
sticky top-0 z-1 w-full p1 bg-base border="b base"
7063
>
71-
<VueDropdown placement="left-start" :distance :skidding="5" trigger="click" :shown="showDocking" class="w-full">
64+
<VueDropdown placement="left-start" :distance="dropdownDistance" :skidding="5" trigger="click" :shown="showDocking" class="w-full">
7265
<button
7366
ref="buttonDocking"
7467
flex="~ items-center justify-center gap-2"

0 commit comments

Comments
 (0)