Skip to content

Commit b95c255

Browse files
address greptile comments
1 parent 60205f0 commit b95c255

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,16 @@ export function ResourceTabs({
184184
const node = scrollNodeRef.current
185185
if (!node || !activeId) return
186186
const tab = node.querySelector<HTMLElement>(`[data-resource-tab-id="${CSS.escape(activeId)}"]`)
187-
tab?.scrollIntoView({ behavior: 'smooth', block: 'nearest', inline: 'nearest' })
187+
if (!tab) return
188+
const tabLeft = tab.offsetLeft
189+
const tabRight = tabLeft + tab.offsetWidth
190+
const viewLeft = node.scrollLeft
191+
const viewRight = viewLeft + node.clientWidth
192+
if (tabLeft < viewLeft) {
193+
node.scrollTo({ left: tabLeft, behavior: 'smooth' })
194+
} else if (tabRight > viewRight) {
195+
node.scrollTo({ left: tabRight - node.clientWidth, behavior: 'smooth' })
196+
}
188197
}, [activeId])
189198

190199
const addResource = useAddChatResource(chatId)

apps/sim/app/workspace/[workspaceId]/w/components/sidebar/components/workspace-header/workspace-header.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ import { useSettingsNavigation } from '@/hooks/use-settings-navigation'
3535

3636
const logger = createLogger('WorkspaceHeader')
3737

38+
/** Minimum workspace count before the search input and keyboard navigation are shown. */
39+
const WORKSPACE_SEARCH_THRESHOLD = 3
40+
3841
interface WorkspaceHeaderProps {
3942
/** The active workspace object */
4043
activeWorkspace?: { name: string } | null
@@ -492,7 +495,7 @@ export function WorkspaceHeader({
492495
</div>
493496
</div>
494497

495-
{workspaces.length > 3 && (
498+
{workspaces.length > WORKSPACE_SEARCH_THRESHOLD && (
496499
<div className='mt-1 flex items-center gap-1.5 rounded-md border border-[var(--border)] bg-transparent px-2 py-1 transition-colors duration-100 dark:bg-[var(--surface-4)] dark:hover-hover:border-[var(--border-1)] dark:hover-hover:bg-[var(--surface-5)]'>
497500
<Search
498501
className='h-[12px] w-[12px] flex-shrink-0 text-[var(--text-tertiary)]'
@@ -607,6 +610,7 @@ export function WorkspaceHeader({
607610
menuOpenWorkspaceId === workspace.id) &&
608611
'bg-[var(--surface-active)]',
609612
idx === highlightedIndex &&
613+
workspaces.length > WORKSPACE_SEARCH_THRESHOLD &&
610614
workspace.id !== workspaceId &&
611615
menuOpenWorkspaceId !== workspace.id &&
612616
'bg-[var(--surface-hover)]'

0 commit comments

Comments
 (0)