Skip to content

Commit 6d05b64

Browse files
committed
improvement(chat): display; improvement(emcn): popover attributes
1 parent 744c5f7 commit 6d05b64

File tree

3 files changed

+59
-31
lines changed

3 files changed

+59
-31
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,7 @@ export function Chat() {
569569

570570
return (
571571
<div
572-
className='fixed z-30 flex flex-col overflow-hidden rounded-[6px] bg-[var(--surface-1)] px-[10px] pt-[2px] pb-[8px]'
572+
className='fixed z-30 flex flex-col overflow-hidden rounded-[6px] border border-[var(--border)] bg-[var(--surface-1)] px-[10px] pt-[2px] pb-[8px]'
573573
style={{
574574
left: `${actualPosition.x}px`,
575575
top: `${actualPosition.y}px`,
@@ -619,6 +619,7 @@ export function Chat() {
619619
side='bottom'
620620
align='end'
621621
sideOffset={8}
622+
maxHeight={100}
622623
style={{ width: '110px', minWidth: '110px' }}
623624
>
624625
<PopoverScrollArea>

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/chat/components/output-select/output-select.tsx

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -288,36 +288,41 @@ export function OutputSelect({
288288
<PopoverContent
289289
ref={popoverRef}
290290
side='bottom'
291-
align='start'
291+
align='end'
292292
sideOffset={4}
293-
maxHeight={280}
293+
maxHeight={140}
294+
maxWidth={140}
295+
minWidth={140}
294296
onOpenAutoFocus={(e) => e.preventDefault()}
295297
onCloseAutoFocus={(e) => e.preventDefault()}
296298
>
297299
<PopoverScrollArea className='space-y-[2px]'>
298300
{Object.entries(groupedOutputs).map(([blockName, outputs]) => (
299301
<div key={blockName}>
300302
<PopoverSection>{blockName}</PopoverSection>
301-
{outputs.map((output) => (
302-
<PopoverItem
303-
key={output.id}
304-
active={isSelectedValue(output)}
305-
onClick={() => handleOutputSelection(output.label)}
306-
>
307-
<div
308-
className='flex h-[14px] w-[14px] flex-shrink-0 items-center justify-center rounded'
309-
style={{
310-
backgroundColor: getOutputColor(output.blockId, output.blockType),
311-
}}
303+
304+
<div className='flex flex-col gap-[2px]'>
305+
{outputs.map((output) => (
306+
<PopoverItem
307+
key={output.id}
308+
active={isSelectedValue(output)}
309+
onClick={() => handleOutputSelection(output.label)}
312310
>
313-
<span className='font-bold text-[10px] text-white'>
314-
{blockName.charAt(0).toUpperCase()}
315-
</span>
316-
</div>
317-
<span className='min-w-0 flex-1 truncate'>{output.path}</span>
318-
{isSelectedValue(output) && <Check className='h-3 w-3 flex-shrink-0' />}
319-
</PopoverItem>
320-
))}
311+
<div
312+
className='flex h-[14px] w-[14px] flex-shrink-0 items-center justify-center rounded'
313+
style={{
314+
backgroundColor: getOutputColor(output.blockId, output.blockType),
315+
}}
316+
>
317+
<span className='font-bold text-[10px] text-white'>
318+
{blockName.charAt(0).toUpperCase()}
319+
</span>
320+
</div>
321+
<span className='min-w-0 flex-1 truncate'>{output.path}</span>
322+
{isSelectedValue(output) && <Check className='h-3 w-3 flex-shrink-0' />}
323+
</PopoverItem>
324+
))}
325+
</div>
321326
</div>
322327
))}
323328
</PopoverScrollArea>

apps/sim/components/emcn/components/popover/popover.tsx

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,15 @@ export interface PopoverContentProps
205205
* Maximum height for the popover content in pixels
206206
*/
207207
maxHeight?: number
208+
/**
209+
* Maximum width for the popover content in pixels.
210+
* When provided, Popover will also enable default truncation for inner text and section headers.
211+
*/
212+
maxWidth?: number
213+
/**
214+
* Minimum width for the popover content in pixels
215+
*/
216+
minWidth?: number
208217
/**
209218
* Preferred side to display the popover
210219
* @default 'bottom'
@@ -249,6 +258,8 @@ const PopoverContent = React.forwardRef<
249258
style,
250259
children,
251260
maxHeight,
261+
maxWidth,
262+
minWidth,
252263
side = 'bottom',
253264
align = 'start',
254265
sideOffset,
@@ -264,7 +275,11 @@ const PopoverContent = React.forwardRef<
264275
// When present, we enable default text truncation behavior for inner flexible items,
265276
// so callers don't need to manually pass 'truncate' to every label.
266277
const hasUserWidthConstraint =
267-
style?.minWidth !== undefined || style?.maxWidth !== undefined || style?.width !== undefined
278+
maxWidth !== undefined ||
279+
minWidth !== undefined ||
280+
style?.minWidth !== undefined ||
281+
style?.maxWidth !== undefined ||
282+
style?.width !== undefined
268283

269284
return (
270285
<PopoverPrimitive.Portal>
@@ -278,15 +293,21 @@ const PopoverContent = React.forwardRef<
278293
sticky='partial'
279294
{...restProps}
280295
className={cn(
281-
'z-[10000001] flex flex-col overflow-hidden rounded-[8px] bg-[var(--surface-3)] px-[5.5px] py-[5px] text-foreground outline-none dark:bg-[var(--surface-3)]',
282-
// If width is constrained by the caller, ensure inner flexible text truncates by default.
283-
hasUserWidthConstraint && '[&_.flex-1]:truncate',
284-
className
296+
'z-[10000001] flex flex-col overflow-auto rounded-[8px] bg-[var(--surface-3)] px-[5.5px] py-[5px] text-foreground outline-none dark:bg-[var(--surface-3)]',
297+
// If width is constrained by the caller (prop or style), ensure inner flexible text truncates by default,
298+
// and also truncate section headers.
299+
hasUserWidthConstraint && '[&_.flex-1]:truncate [&_[data-popover-section]]:truncate',
285300
)}
286301
style={{
287302
maxHeight: `${maxHeight || 400}px`,
288-
maxWidth: 'calc(100vw - 16px)',
289-
minWidth: '160px',
303+
maxWidth: maxWidth !== undefined ? `${maxWidth}px` : 'calc(100vw - 16px)',
304+
// Only enforce default min width when the user hasn't set width constraints
305+
minWidth:
306+
minWidth !== undefined
307+
? `${minWidth}px`
308+
: hasUserWidthConstraint
309+
? undefined
310+
: '160px',
290311
...style,
291312
}}
292313
>
@@ -319,7 +340,7 @@ const PopoverScrollArea = React.forwardRef<HTMLDivElement, PopoverScrollAreaProp
319340
({ className, ...props }, ref) => {
320341
return (
321342
<div
322-
className={cn('min-h-0 flex-1 overflow-auto overscroll-contain', className)}
343+
className={cn('min-h-0 overflow-auto overscroll-contain', className)}
323344
ref={ref}
324345
{...props}
325346
/>
@@ -415,9 +436,10 @@ const PopoverSection = React.forwardRef<HTMLDivElement, PopoverSectionProps>(
415436
return (
416437
<div
417438
className={cn(
418-
'px-[6px] py-[4px] font-base text-[12px] text-[var(--text-tertiary)] dark:text-[var(--text-tertiary)]',
439+
'min-w-0 px-[6px] py-[4px] font-base text-[12px] text-[var(--text-tertiary)] dark:text-[var(--text-tertiary)]',
419440
className
420441
)}
442+
data-popover-section=''
421443
ref={ref}
422444
{...props}
423445
/>

0 commit comments

Comments
 (0)