Skip to content

Commit 27f328f

Browse files
committed
fix(tables): keep row context menu labels on one line
1 parent 6c6d8a5 commit 27f328f

2 files changed

Lines changed: 22 additions & 9 deletions

File tree

apps/sim/app/workspace/[workspaceId]/tables/[tableId]/components/context-menu/context-menu.tsx

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -146,17 +146,22 @@ export function ContextMenu({
146146
aria-hidden
147147
/>
148148
</DropdownMenuTrigger>
149+
{/* Wider than the 220px menu default: the row-scoped workflow labels name
150+
both the action and the selected row count ("Run empty or failed cells
151+
on 2 rows"), which wrapped — and so overlapped the rows beneath — at
152+
the default width. */}
149153
<DropdownMenuContent
150154
align='start'
151155
side='bottom'
152156
sideOffset={4}
157+
className='max-w-[320px]'
153158
onCloseAutoFocus={(e) => e.preventDefault()}
154159
>
155160
{onAddToChat && (
156161
<>
157162
<DropdownMenuItem onSelect={onAddToChat}>
158163
<Blimp />
159-
{addToChatLabel}
164+
<span>{addToChatLabel}</span>
160165
</DropdownMenuItem>
161166
<DropdownMenuSeparator />
162167
</>
@@ -179,19 +184,19 @@ export function ContextMenu({
179184
{hasWorkflowColumns && onRunWorkflows && (
180185
<DropdownMenuItem onSelect={onRunWorkflows}>
181186
<PlayOutline />
182-
{runLabel}
187+
<span>{runLabel}</span>
183188
</DropdownMenuItem>
184189
)}
185190
{hasWorkflowColumns && onRefreshWorkflows && (
186191
<DropdownMenuItem onSelect={onRefreshWorkflows}>
187192
<RefreshCw />
188-
{refreshLabel}
193+
<span>{refreshLabel}</span>
189194
</DropdownMenuItem>
190195
)}
191196
{hasWorkflowColumns && onStopWorkflows && runningInSelectionCount > 0 && (
192197
<DropdownMenuItem onSelect={onStopWorkflows}>
193198
<Square className='size-[14px] text-[var(--text-icon)]' />
194-
{stopLabel}
199+
<span>{stopLabel}</span>
195200
</DropdownMenuItem>
196201
)}
197202
<DropdownMenuItem disabled={disableInsert} onSelect={onInsertAbove}>
@@ -212,7 +217,7 @@ export function ContextMenu({
212217
<DropdownMenuSeparator />
213218
<DropdownMenuItem disabled={disableDelete} onSelect={onDelete}>
214219
<Trash />
215-
{deleteLabel}
220+
<span>{deleteLabel}</span>
216221
</DropdownMenuItem>
217222
</DropdownMenuContent>
218223
</DropdownMenu>

packages/emcn/src/components/dropdown-menu/dropdown-menu.tsx

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,14 @@ const ANIMATION_CLASSES =
4040
const MENU_ROW_HEIGHT_CLASS = 'h-[28px]'
4141
const MENU_ROW_RADIUS_CLASS = 'rounded-lg'
4242

43+
/**
44+
* Rows are a fixed height, so a label that wraps overflows its row and paints
45+
* over its neighbours instead of growing the row. Keep every row on one line:
46+
* a bare text label is clipped at the surface edge, and a label wrapped in a
47+
* `<span>` (the shape long or count-bearing labels should use) ellipsizes.
48+
*/
49+
const MENU_ROW_SINGLE_LINE_CLASS = 'whitespace-nowrap [&>span]:min-w-0 [&>span]:truncate'
50+
4351
/**
4452
* Surface corner, shared by the root menu and submenus — they previously
4553
* disagreed, at 12px and 8px.
@@ -110,7 +118,7 @@ const DropdownMenuSubTrigger = React.forwardRef<
110118
<DropdownMenuPrimitive.SubTrigger
111119
ref={ref}
112120
className={cn(
113-
`flex ${MENU_ROW_HEIGHT_CLASS} min-w-0 cursor-default select-none items-center gap-2 ${MENU_ROW_RADIUS_CLASS} px-2 text-[var(--text-body)] text-small outline-none transition-colors focus:bg-[var(--surface-active)] data-[state=open]:bg-[var(--surface-active)] [&>span]:min-w-0 [&>span]:truncate [&_svg]:pointer-events-none [&_svg]:size-[14px] [&_svg]:shrink-0 [&_svg]:text-[var(--text-icon)]`,
121+
`flex ${MENU_ROW_HEIGHT_CLASS} min-w-0 cursor-default select-none items-center gap-2 ${MENU_ROW_RADIUS_CLASS} px-2 text-[var(--text-body)] text-small outline-none transition-colors focus:bg-[var(--surface-active)] data-[state=open]:bg-[var(--surface-active)] ${MENU_ROW_SINGLE_LINE_CLASS} [&_svg]:pointer-events-none [&_svg]:size-[14px] [&_svg]:shrink-0 [&_svg]:text-[var(--text-icon)]`,
114122
inset && 'pl-7',
115123
className
116124
)}
@@ -172,7 +180,7 @@ const DropdownMenuContent = React.forwardRef<
172180
))
173181
DropdownMenuContent.displayName = DropdownMenuPrimitive.Content.displayName
174182

175-
const DROPDOWN_MENU_ITEM_BASE_CLASSES = `relative flex ${MENU_ROW_HEIGHT_CLASS} min-w-0 cursor-pointer select-none items-center gap-2 ${MENU_ROW_RADIUS_CLASS} px-2 text-[var(--text-body)] text-small outline-none transition-colors focus:bg-[var(--surface-active)] data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&>span]:min-w-0 [&>span]:truncate [&_svg]:pointer-events-none [&_svg]:size-[14px] [&_svg]:shrink-0 [&_svg]:text-[var(--text-icon)]`
183+
const DROPDOWN_MENU_ITEM_BASE_CLASSES = `relative flex ${MENU_ROW_HEIGHT_CLASS} min-w-0 cursor-pointer select-none items-center gap-2 ${MENU_ROW_RADIUS_CLASS} px-2 text-[var(--text-body)] text-small outline-none transition-colors focus:bg-[var(--surface-active)] data-[disabled]:pointer-events-none data-[disabled]:opacity-50 ${MENU_ROW_SINGLE_LINE_CLASS} [&_svg]:pointer-events-none [&_svg]:size-[14px] [&_svg]:shrink-0 [&_svg]:text-[var(--text-icon)]`
176184

177185
const DropdownMenuItem = React.forwardRef<
178186
React.ElementRef<typeof DropdownMenuPrimitive.Item>,
@@ -252,7 +260,7 @@ const DropdownMenuCheckboxItem = React.forwardRef<
252260
<DropdownMenuPrimitive.CheckboxItem
253261
ref={ref}
254262
className={cn(
255-
`relative flex ${MENU_ROW_HEIGHT_CLASS} cursor-default select-none items-center ${MENU_ROW_RADIUS_CLASS} pr-2 pl-7 text-[var(--text-body)] text-small outline-none transition-colors focus:bg-[var(--surface-active)] data-[disabled]:pointer-events-none data-[disabled]:opacity-50`,
263+
`relative flex ${MENU_ROW_HEIGHT_CLASS} cursor-default select-none items-center ${MENU_ROW_RADIUS_CLASS} whitespace-nowrap pr-2 pl-7 text-[var(--text-body)] text-small outline-none transition-colors focus:bg-[var(--surface-active)] data-[disabled]:pointer-events-none data-[disabled]:opacity-50`,
256264
className
257265
)}
258266
checked={checked}
@@ -275,7 +283,7 @@ const DropdownMenuRadioItem = React.forwardRef<
275283
<DropdownMenuPrimitive.RadioItem
276284
ref={ref}
277285
className={cn(
278-
`relative flex ${MENU_ROW_HEIGHT_CLASS} cursor-default select-none items-center ${MENU_ROW_RADIUS_CLASS} pr-2 pl-7 text-[var(--text-body)] text-small outline-none transition-colors focus:bg-[var(--surface-active)] data-[disabled]:pointer-events-none data-[disabled]:opacity-50`,
286+
`relative flex ${MENU_ROW_HEIGHT_CLASS} cursor-default select-none items-center ${MENU_ROW_RADIUS_CLASS} whitespace-nowrap pr-2 pl-7 text-[var(--text-body)] text-small outline-none transition-colors focus:bg-[var(--surface-active)] data-[disabled]:pointer-events-none data-[disabled]:opacity-50`,
279287
className
280288
)}
281289
{...props}

0 commit comments

Comments
 (0)