Skip to content

Commit bc82505

Browse files
committed
Hide document tab scrollbar on all platforms
1 parent 7de950f commit bc82505

2 files changed

Lines changed: 33 additions & 2 deletions

File tree

components/DocumentTabs.tsx

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,10 +196,12 @@ const DocumentTabs: React.FC<DocumentTabsProps> = ({
196196
const tabStart = element.offsetLeft;
197197
if (tabStart < scrollLeft - 1) {
198198
container.scrollTo({ left: tabStart, behavior: 'smooth' });
199+
requestAnimationFrame(() => updateScrollState());
199200
return;
200201
}
201202
}
202203
container.scrollTo({ left: 0, behavior: 'smooth' });
204+
requestAnimationFrame(() => updateScrollState());
203205
} else {
204206
for (let index = 0; index < openDocumentIds.length; index += 1) {
205207
const id = openDocumentIds[index];
@@ -208,12 +210,33 @@ const DocumentTabs: React.FC<DocumentTabsProps> = ({
208210
const tabEnd = element.offsetLeft + element.offsetWidth;
209211
if (tabEnd > scrollLeft + clientWidth + 1) {
210212
container.scrollTo({ left: tabEnd - clientWidth, behavior: 'smooth' });
213+
requestAnimationFrame(() => updateScrollState());
211214
return;
212215
}
213216
}
214217
container.scrollTo({ left: container.scrollWidth - clientWidth, behavior: 'smooth' });
218+
requestAnimationFrame(() => updateScrollState());
215219
}
216-
}, [openDocumentIds]);
220+
}, [openDocumentIds, updateScrollState]);
221+
222+
const handleWheel = useCallback((event: React.WheelEvent<HTMLDivElement>) => {
223+
const container = scrollContainerRef.current;
224+
if (!container) return;
225+
226+
const dominantDelta = Math.abs(event.deltaX) >= Math.abs(event.deltaY)
227+
? event.deltaX
228+
: event.shiftKey
229+
? event.deltaY
230+
: 0;
231+
232+
if (dominantDelta === 0) {
233+
return;
234+
}
235+
236+
event.preventDefault();
237+
container.scrollBy({ left: dominantDelta });
238+
requestAnimationFrame(() => updateScrollState());
239+
}, [updateScrollState]);
217240

218241
const handleDragStart = useCallback((event: React.DragEvent<HTMLDivElement>, tabId: string, index: number) => {
219242
dragState.current = { id: tabId, index };
@@ -330,9 +353,10 @@ const DocumentTabs: React.FC<DocumentTabsProps> = ({
330353
<div className="flex-1 h-full relative overflow-hidden">
331354
<div
332355
ref={scrollContainerRef}
333-
className="absolute inset-y-0 left-0 right-0 overflow-x-auto overflow-y-hidden scrollbar-hidden"
356+
className="absolute inset-y-0 left-0 right-0 overflow-hidden scrollbar-hidden"
334357
onDragOver={handleDragOver}
335358
onDrop={handleContainerDrop}
359+
onWheel={handleWheel}
336360
role="tablist"
337361
>
338362
<div className="flex items-stretch gap-1 h-full min-w-max pr-2">

styles/tailwind.css

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,17 @@
66
scrollbar-width: none !important;
77
-ms-overflow-style: none !important;
88
scrollbar-color: transparent transparent !important;
9+
scrollbar-gutter: stable both-edges;
910
}
1011

1112
.scrollbar-hidden::-webkit-scrollbar {
1213
width: 0 !important;
1314
height: 0 !important;
1415
display: none !important;
1516
}
17+
18+
.scrollbar-hidden::-webkit-scrollbar-track,
19+
.scrollbar-hidden::-webkit-scrollbar-thumb {
20+
background: transparent !important;
21+
border: none !important;
22+
}

0 commit comments

Comments
 (0)