Skip to content

Commit 184509f

Browse files
authored
fixes: scrollWidth undefined issue (#38)
1 parent 7e0faa2 commit 184509f

File tree

2 files changed

+18
-13
lines changed

2 files changed

+18
-13
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@hoppscotch/ui",
3-
"version": "0.2.3",
3+
"version": "0.2.4",
44
"license": "MIT",
55
"description": "Hoppscotch UI",
66
"author": "Hoppscotch ([email protected])",

src/components/smart/Windows.vue

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
<template>
2-
<div class="flex flex-col flex-1 h-auto overflow-y-hidden flex-nowrap">
2+
<div class="flex h-auto flex-1 flex-col flex-nowrap overflow-y-hidden">
33
<div
4-
class="sticky top-0 z-10 flex-shrink-0 overflow-x-auto tabs group-tabs divide-x divide-dividerLight bg-primaryLight"
4+
class="tabs group-tabs sticky top-0 z-10 flex-shrink-0 divide-x divide-dividerLight overflow-x-auto bg-primaryLight"
55
>
66
<div
7-
class="flex flex-1 flex-shrink-0 w-0 overflow-hidden"
7+
class="flex w-0 flex-1 flex-shrink-0 overflow-hidden"
88
ref="scrollContainer"
99
>
1010
<div
@@ -17,7 +17,7 @@
1717
:list="tabEntries"
1818
:style="tabStyles"
1919
:item-key="'window-'"
20-
class="flex flex-shrink-0 overflow-x-auto divide-x divide-dividerLight transition"
20+
class="flex flex-shrink-0 divide-x divide-dividerLight overflow-x-auto transition"
2121
@sort="sortTabs"
2222
>
2323
<template #item="{ element: [tabID, tabMeta] }">
@@ -33,21 +33,21 @@
3333
>
3434
<span
3535
v-if="tabMeta.icon"
36-
class="flex items-center justify-center cursor-pointer"
36+
class="flex cursor-pointer items-center justify-center"
3737
>
38-
<component :is="tabMeta.icon" class="w-4 h-4 svg-icons" />
38+
<component :is="tabMeta.icon" class="svg-icons h-4 w-4" />
3939
</span>
4040

4141
<div
4242
v-if="!tabMeta.tabhead"
43-
class="w-full px-2 text-left truncate"
43+
class="w-full truncate px-2 text-left"
4444
>
4545
<span class="truncate">
4646
{{ tabMeta.label }}
4747
</span>
4848
</div>
4949

50-
<div v-else class="w-full text-left truncate">
50+
<div v-else class="w-full truncate text-left">
5151
<component :is="tabMeta.tabhead" />
5252
</div>
5353

@@ -81,7 +81,7 @@
8181
</draggable>
8282
</div>
8383
<div
84-
class="sticky right-0 z-20 flex items-center justify-center flex-shrink-0 overflow-x-auto"
84+
class="sticky right-0 z-20 flex flex-shrink-0 items-center justify-center overflow-x-auto"
8585
>
8686
<span
8787
v-if="canAddNewTab"
@@ -109,7 +109,7 @@
109109
min="1"
110110
:max="MAX_SCROLL_VALUE"
111111
v-model="thumbPosition"
112-
class="absolute bottom-0 left-0 hidden slider"
112+
class="slider absolute bottom-0 left-0 hidden"
113113
:class="{
114114
'!block': scrollThumb.show,
115115
}"
@@ -122,7 +122,7 @@
122122
id="myRange"
123123
/>
124124
</div>
125-
<div class="w-full h-full contents">
125+
<div class="contents h-full w-full">
126126
<slot></slot>
127127
</div>
128128
</div>
@@ -306,7 +306,12 @@ const scroll = (e: WheelEvent) => {
306306
scrollContainer.value!.scrollLeft += e.deltaY
307307
scrollContainer.value!.scrollLeft += e.deltaX
308308
309-
const { scrollWidth, clientWidth, scrollLeft } = scrollContainer.value!
309+
const { scrollWidth, clientWidth, scrollLeft } = scrollContainer.value || {
310+
scrollWidth: 0,
311+
clientWidth: 0,
312+
scrollLeft: 0,
313+
}
314+
310315
const maxScroll = scrollWidth - clientWidth
311316
thumbPosition.value = (scrollLeft / maxScroll) * MAX_SCROLL_VALUE
312317
}

0 commit comments

Comments
 (0)