Skip to content

Commit 1edfc47

Browse files
committed
fix(combobox): show selected values in multi-select trigger label
The collapsed trigger was reading only `selectedOption` (the single-value path) and falling back to the placeholder when nothing matched, so a multi-select dropdown with 1+ checked items still rendered "Select one or more channels" instead of the actual selections. Added `multiSelectLabel` derived from `multiSelectValues`: - 1 value → that label - 2 values → "A, B" - 3+ → "A, B +N" Trigger now prefers `multiSelectLabel` when present and falls back to the single-select label / placeholder otherwise. Muted-text color also flips off when multi has any selection.
1 parent 1afa881 commit 1edfc47

1 file changed

Lines changed: 18 additions & 2 deletions

File tree

apps/sim/components/emcn/components/combobox/combobox.tsx

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,22 @@ const Combobox = memo(
214214
[allOptions, effectiveSelectedValue]
215215
)
216216

217+
/**
218+
* Label rendered in the collapsed trigger for multi-select mode.
219+
* Shows the single label when one value is picked, comma-joined labels
220+
* for two, or "first, second +N" when more are selected. Falls back to
221+
* the raw value if an option for it hasn't loaded yet.
222+
*/
223+
const multiSelectLabel = useMemo(() => {
224+
if (!multiSelect || !multiSelectValues || multiSelectValues.length === 0) return null
225+
const labelFor = (v: string) => allOptions.find((opt) => opt.value === v)?.label ?? v
226+
if (multiSelectValues.length === 1) return labelFor(multiSelectValues[0])
227+
if (multiSelectValues.length === 2) {
228+
return `${labelFor(multiSelectValues[0])}, ${labelFor(multiSelectValues[1])}`
229+
}
230+
return `${labelFor(multiSelectValues[0])}, ${labelFor(multiSelectValues[1])} +${multiSelectValues.length - 2}`
231+
}, [multiSelect, multiSelectValues, allOptions])
232+
217233
/**
218234
* Filter options based on current value or search query
219235
*/
@@ -590,11 +606,11 @@ const Combobox = memo(
590606
<span
591607
className={cn(
592608
'flex-1 truncate',
593-
!selectedOption && 'text-[var(--text-muted)]',
609+
!selectedOption && !multiSelectLabel && 'text-[var(--text-muted)]',
594610
overlayContent && 'text-transparent'
595611
)}
596612
>
597-
{selectedOption ? selectedOption.label : placeholder}
613+
{multiSelectLabel ?? (selectedOption ? selectedOption.label : placeholder)}
598614
</span>
599615
<ChevronDown
600616
className={cn(

0 commit comments

Comments
 (0)