Skip to content

Commit f161c26

Browse files
author
Theodore Li
committed
feat(resource-tab-scroll): Allow vertical scrolling to scroll resource tab
1 parent d347b8c commit f161c26

File tree

1 file changed

+17
-2
lines changed
  • apps/sim/app/workspace/[workspaceId]/home/components/mothership-view/components/resource-tabs

1 file changed

+17
-2
lines changed

apps/sim/app/workspace/[workspaceId]/home/components/mothership-view/components/resource-tabs/resource-tabs.tsx

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use client'
22

3-
import type { ElementType, ReactNode, SVGProps } from 'react'
3+
import { type ElementType, type ReactNode, type RefCallback, type SVGProps, useCallback } from 'react'
44
import { Button, Tooltip } from '@/components/emcn'
55
import { PanelLeft, Table as TableIcon } from '@/components/emcn/icons'
66
import { WorkflowIcon } from '@/components/icons'
@@ -76,6 +76,18 @@ export function ResourceTabs({
7676
onCyclePreviewMode,
7777
actions,
7878
}: ResourceTabsProps) {
79+
const scrollRef = useCallback<RefCallback<HTMLDivElement>>((node) => {
80+
if (!node) return
81+
const handler = (e: WheelEvent) => {
82+
if (e.deltaY !== 0) {
83+
node.scrollLeft += e.deltaY
84+
e.preventDefault()
85+
}
86+
}
87+
node.addEventListener('wheel', handler, { passive: false })
88+
return () => node.removeEventListener('wheel', handler)
89+
}, [])
90+
7991
return (
8092
<div className='flex shrink-0 items-center border-[var(--border)] border-b px-[16px] py-[8.5px]'>
8193
<Tooltip.Root>
@@ -93,7 +105,10 @@ export function ResourceTabs({
93105
<p>Collapse</p>
94106
</Tooltip.Content>
95107
</Tooltip.Root>
96-
<div className='mx-[2px] flex min-w-0 items-center gap-[6px] overflow-x-auto px-[6px] [scrollbar-width:none] [&::-webkit-scrollbar]:hidden'>
108+
<div
109+
ref={scrollRef}
110+
className='mx-[2px] flex min-w-0 items-center gap-[6px] overflow-x-auto px-[6px] [scrollbar-width:none] [&::-webkit-scrollbar]:hidden'
111+
>
97112
{resources.map((resource) => {
98113
const Icon = getResourceIcon(resource)
99114
const isActive = activeId === resource.id

0 commit comments

Comments
 (0)