Skip to content

Commit 64cdab2

Browse files
fix(ui): handle long file paths and names in search modal (#4155)
* fix(ui): handle long file paths and names in search modal * Handle long subfolder names * fix memo
1 parent a51333a commit 64cdab2

File tree

4 files changed

+27
-19
lines changed

4 files changed

+27
-19
lines changed

apps/sim/app/workspace/[workspaceId]/w/components/sidebar/components/search-modal/components/command-items.tsx

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ export const MemoizedWorkflowItem = memo(
5858
onSelect: () => void
5959
color: string
6060
name: string
61-
folderPath?: string
61+
folderPath?: string[]
6262
isCurrent?: boolean
6363
}) {
6464
return (
@@ -71,13 +71,21 @@ export const MemoizedWorkflowItem = memo(
7171
backgroundClip: 'padding-box',
7272
}}
7373
/>
74-
<span className='truncate font-base text-[var(--text-body)]'>
75-
{name}
76-
{isCurrent && ' (current)'}
74+
<span className='flex min-w-0 max-w-[75%] flex-shrink-0 font-base text-[var(--text-body)]'>
75+
<span className='truncate'>{name}</span>
76+
{isCurrent && <span className='flex-shrink-0 whitespace-pre'> (current)</span>}
7777
</span>
78-
{folderPath && (
79-
<span className='ml-auto min-w-0 truncate pl-2 font-base text-[var(--text-subtle)] text-small'>
80-
{folderPath}
78+
{folderPath && folderPath.length > 0 && (
79+
<span className='ml-auto flex min-w-0 pl-2 font-base text-[var(--text-subtle)] text-small'>
80+
{folderPath.length > 1 && (
81+
<>
82+
<span className='min-w-0 truncate [flex-shrink:9999]'>
83+
{folderPath.slice(0, -1).join(' / ')}
84+
</span>
85+
<span className='flex-shrink-0 whitespace-pre'> / </span>
86+
</>
87+
)}
88+
<span className='min-w-0 truncate'>{folderPath[folderPath.length - 1]}</span>
8189
</span>
8290
)}
8391
</Command.Item>
@@ -87,8 +95,10 @@ export const MemoizedWorkflowItem = memo(
8795
prev.value === next.value &&
8896
prev.color === next.color &&
8997
prev.name === next.name &&
90-
prev.folderPath === next.folderPath &&
91-
prev.isCurrent === next.isCurrent
98+
prev.isCurrent === next.isCurrent &&
99+
(prev.folderPath === next.folderPath ||
100+
(prev.folderPath?.length === next.folderPath?.length &&
101+
(prev.folderPath ?? []).every((segment, i) => segment === next.folderPath?.[i])))
92102
)
93103

94104
export const MemoizedTaskItem = memo(
@@ -127,9 +137,9 @@ export const MemoizedWorkspaceItem = memo(
127137
}) {
128138
return (
129139
<Command.Item value={value} onSelect={onSelect} className={COMMAND_ITEM_CLASSNAME}>
130-
<span className='truncate font-base text-[var(--text-body)]'>
131-
{name}
132-
{isCurrent && ' (current)'}
140+
<span className='flex min-w-0 font-base text-[var(--text-body)]'>
141+
<span className='truncate'>{name}</span>
142+
{isCurrent && <span className='flex-shrink-0 whitespace-pre'> (current)</span>}
133143
</span>
134144
</Command.Item>
135145
)

apps/sim/app/workspace/[workspaceId]/w/components/sidebar/components/search-modal/components/search-groups.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ export const WorkflowsGroup = memo(function WorkflowsGroup({
163163
{items.map((workflow) => (
164164
<MemoizedWorkflowItem
165165
key={workflow.id}
166-
value={`${workflow.name} ${workflow.folderPath ?? ''} workflow-${workflow.id}`}
166+
value={`${workflow.name} ${workflow.folderPath?.join(' / ') ?? ''} workflow-${workflow.id}`}
167167
onSelect={() => onSelect(workflow)}
168168
color={workflow.color}
169169
name={workflow.name}

apps/sim/app/workspace/[workspaceId]/w/components/sidebar/components/search-modal/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export interface WorkflowItem {
1111
name: string
1212
href: string
1313
color: string
14-
folderPath?: string
14+
folderPath?: string[]
1515
isCurrent?: boolean
1616
}
1717

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

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -637,16 +637,14 @@ export const Sidebar = memo(function Sidebar() {
637637
() =>
638638
regularWorkflows.map((workflow) => {
639639
const folderPath = workflow.folderId
640-
? getFolderPath(folderMap, workflow.folderId)
641-
.map((folder) => folder.name)
642-
.join(' / ')
643-
: ''
640+
? getFolderPath(folderMap, workflow.folderId).map((folder) => folder.name)
641+
: []
644642
return {
645643
id: workflow.id,
646644
name: workflow.name,
647645
href: `/workspace/${workspaceId}/w/${workflow.id}`,
648646
color: workflow.color,
649-
folderPath: folderPath || undefined,
647+
folderPath: folderPath.length > 0 ? folderPath : undefined,
650648
isCurrent: workflow.id === workflowId,
651649
}
652650
}),

0 commit comments

Comments
 (0)