Skip to content

Commit c06fb82

Browse files
committed
fix(search): fix icon in model dropdown search
1 parent 04286fc commit c06fb82

File tree

1 file changed

+29
-4
lines changed
  • apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/combobox

1 file changed

+29
-4
lines changed

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/combobox/combobox.tsx

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -442,12 +442,37 @@ export const ComboBox = memo(function ComboBox({
442442
)
443443

444444
/**
445-
* Gets the icon for the currently selected option
445+
* Gets the icon for the currently selected option.
446+
* Uses prefix/partial matching to show icon while user is typing a search query.
446447
*/
447448
const selectedOption = useMemo(() => {
448-
if (!value) return undefined
449-
return comboboxOptions.find((opt) => opt.value === value)
450-
}, [comboboxOptions, value])
449+
// First try exact match on stored value
450+
if (value) {
451+
const exactMatch = comboboxOptions.find((opt) => opt.value === value)
452+
if (exactMatch) return exactMatch
453+
}
454+
455+
// Try prefix match on input text (while user is typing to search/filter)
456+
if (inputValue) {
457+
const inputLower = inputValue.toLowerCase()
458+
const prefixMatch = comboboxOptions.find(
459+
(opt) =>
460+
opt.value.toLowerCase().startsWith(inputLower) ||
461+
opt.label.toLowerCase().startsWith(inputLower)
462+
)
463+
if (prefixMatch) return prefixMatch
464+
465+
// Try contains match as fallback
466+
const containsMatch = comboboxOptions.find(
467+
(opt) =>
468+
opt.value.toLowerCase().includes(inputLower) ||
469+
opt.label.toLowerCase().includes(inputLower)
470+
)
471+
if (containsMatch) return containsMatch
472+
}
473+
474+
return undefined
475+
}, [comboboxOptions, value, inputValue])
451476

452477
const selectedOptionIcon = selectedOption?.icon
453478

0 commit comments

Comments
 (0)