Skip to content

Commit faedae9

Browse files
committed
fix(ui): keep editor pickers on shared combobox styling
1 parent af8b8cb commit faedae9

10 files changed

Lines changed: 41 additions & 47 deletions

File tree

‎apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/knowledge-base-selector/knowledge-base-selector.tsx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use client'
22

33
import { useCallback, useMemo } from 'react'
4-
import { ChipCombobox, ChipTag, type ComboboxOption } from '@sim/emcn'
4+
import { ChipTag, Combobox, type ComboboxOption } from '@sim/emcn'
55
import { X } from '@sim/emcn/icons'
66
import { useQueries } from '@tanstack/react-query'
77
import { useParams } from 'next/navigation'
@@ -211,7 +211,7 @@ export function KnowledgeBaseSelector({
211211
</div>
212212
)}
213213

214-
<ChipCombobox
214+
<Combobox
215215
options={options}
216216
value={isMultiSelect ? undefined : (selectedIds[0] ?? '')}
217217
multiSelect={isMultiSelect}

‎apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/mcp-server-modal/mcp-server-selector.tsx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use client'
22

3-
import { ChipCombobox } from '@sim/emcn'
3+
import { Combobox } from '@sim/emcn'
44
import { useParams } from 'next/navigation'
55
import { McpIcon } from '@/components/icons'
66
import { getMcpTargetOptions } from '@/components/mcp/target-options'
@@ -65,7 +65,7 @@ export function McpServerSelector({
6565
})
6666

6767
return (
68-
<ChipCombobox
68+
<Combobox
6969
options={comboboxOptions}
7070
value={inputValue}
7171
selectedValue={selectedServerId}

‎apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/mcp-server-modal/mcp-tool-selector.tsx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use client'
22

33
import { useMemo } from 'react'
4-
import { ChipCombobox } from '@sim/emcn'
4+
import { Combobox } from '@sim/emcn'
55
import { useParams } from 'next/navigation'
66
import { formatDisplayText } from '@/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/formatted-text'
77
import { getWorkflowSearchLabelHighlight } from '@/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/workflow-search-highlight'
@@ -86,7 +86,7 @@ export function McpToolSelector({
8686
})
8787

8888
return (
89-
<ChipCombobox
89+
<Combobox
9090
options={comboboxOptions}
9191
value={inputValue}
9292
selectedValue={selectedToolId}

‎apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/model-fallback-list/model-fallback-list.test.tsx‎

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ vi.mock('@sim/emcn', () => ({
4646
{children}
4747
</button>
4848
),
49-
ChipCombobox: ({
49+
Combobox: ({
5050
options,
5151
value,
5252
placeholder,
@@ -63,21 +63,6 @@ vi.mock('@sim/emcn', () => ({
6363
))}
6464
</div>
6565
),
66-
ChipDropdown: ({
67-
options,
68-
value,
69-
placeholder,
70-
}: {
71-
options: Array<{ value: string; label: string }>
72-
value?: string
73-
placeholder?: string
74-
}) => (
75-
<div data-combobox={placeholder} data-value={value}>
76-
{options.map((option) => (
77-
<span key={option.value}>{option.label}</span>
78-
))}
79-
</div>
80-
),
8166
Label: ({ children }: { children?: React.ReactNode }) => <span>{children}</span>,
8267
Tooltip: {
8368
Root: ({ children }: { children?: React.ReactNode }) => <>{children}</>,

‎apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/model-fallback-list/model-fallback-list.tsx‎

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,7 @@
11
'use client'
22

33
import { memo, useCallback, useEffect, useMemo, useRef } from 'react'
4-
import {
5-
Button,
6-
Chip,
7-
ChipCombobox,
8-
ChipDropdown,
9-
type ComboboxOption,
10-
Label,
11-
Tooltip,
12-
} from '@sim/emcn'
4+
import { Button, Chip, Combobox, type ComboboxOption, Label, Tooltip } from '@sim/emcn'
135
import { ChevronDown, ChevronUp, Plus, Trash } from '@sim/emcn/icons'
146
import { generateShortId } from '@sim/utils/id'
157
import { useParams } from 'next/navigation'
@@ -188,7 +180,7 @@ const FallbackRow = memo(function FallbackRow({
188180
</div>
189181

190182
<div className='flex flex-col gap-2.5 rounded-b-[4px] border-[var(--border)] border-t bg-[var(--surface-2)] p-2'>
191-
<ChipCombobox
183+
<Combobox
192184
options={modelOptions}
193185
value={row.model}
194186
onChange={(model) => onChangeModel(row.id, model)}
@@ -203,7 +195,7 @@ const FallbackRow = memo(function FallbackRow({
203195
{needsApiKey && (
204196
<div className='flex flex-col gap-2.5'>
205197
<Label className='pl-0.5'>API key</Label>
206-
<ChipCombobox
198+
<Combobox
207199
options={envVarOptions}
208200
value={apiKeyValue}
209201
onChange={(apiKey) => onChangeApiKey(row.id, apiKey)}
@@ -220,7 +212,7 @@ const FallbackRow = memo(function FallbackRow({
220212
{tuningFields.map(({ knob, options }) => (
221213
<div key={knob} className='flex flex-col gap-2.5'>
222214
<Label className='pl-0.5'>{FALLBACK_TUNING_LABELS[knob]}</Label>
223-
<ChipDropdown
215+
<Combobox
224216
options={options}
225217
value={row[knob] ?? options[0]?.value ?? ''}
226218
onChange={(value) => onChangeTuning(row.id, knob, value)}

‎apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/workspace-folder-selector/workspace-folder-selector.test.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ vi.mock('next/navigation', () => ({
2020
}))
2121

2222
vi.mock('@sim/emcn', () => ({
23-
ChipCombobox: ({
23+
Combobox: ({
2424
options,
2525
disabled,
2626
isLoading,

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use client'
22

33
import { useMemo } from 'react'
4-
import { ChipCombobox } from '@sim/emcn'
4+
import { Combobox } from '@sim/emcn'
55
import { useParams } from 'next/navigation'
66
import type { FolderResourceType } from '@/lib/api/contracts/folders'
77
import { parseFolderPath } from '@/lib/folders/paths'
@@ -58,7 +58,7 @@ export function WorkspaceFolderSelector({
5858
}, [folders, isPlaceholderData, required, subBlock.multiSelect, subBlock.placeholder])
5959

6060
return (
61-
<ChipCombobox
61+
<Combobox
6262
options={options}
6363
value={subBlock.multiSelect ? undefined : selected}
6464
onChange={(value) => {

‎apps/sim/components/mcp/mcp-selectors.test.tsx‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
/** @vitest-environment node */
22
import type { ComponentProps } from 'react'
3-
import type { ChipCombobox } from '@sim/emcn'
3+
import type { Combobox } from '@sim/emcn'
44
import { renderToStaticMarkup } from 'react-dom/server'
55
import { beforeEach, describe, expect, it, vi } from 'vitest'
66

77
const mocks = vi.hoisted(() => ({
8-
combobox: vi.fn<(props: ComponentProps<typeof ChipCombobox>) => null>(() => null),
8+
combobox: vi.fn<(props: ComponentProps<typeof Combobox>) => null>(() => null),
99
setValue: vi.fn(),
1010
longInput: vi.fn(() => null),
1111
shortInput: vi.fn(() => null),
@@ -38,7 +38,7 @@ vi.mock('@/stores/workflow-diff/store', () => ({
3838
},
3939
}),
4040
}))
41-
vi.mock('@sim/emcn', () => ({ ChipCombobox: mocks.combobox, Label: () => null }))
41+
vi.mock('@sim/emcn', () => ({ Combobox: mocks.combobox, Label: () => null }))
4242
vi.mock(
4343
'@/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/long-input/long-input',
4444
() => ({ LongInput: mocks.longInput })

‎packages/emcn/src/components/combobox/combobox.dom.test.tsx‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,22 @@ afterEach(() => {
7676
})
7777

7878
describe('Combobox onOpenChange', () => {
79+
it('preserves trigger styling when an editable input adds padding for a clear button', () => {
80+
render(
81+
<Combobox
82+
options={OPTIONS}
83+
editable
84+
className='min-w-0'
85+
inputProps={{ className: 'pr-[60px]' }}
86+
/>
87+
)
88+
89+
const control = trigger()
90+
expect(control.classList.contains('min-w-0')).toBe(true)
91+
expect(control.classList.contains('pr-[60px]')).toBe(true)
92+
expect(control.classList.contains('pr-10')).toBe(false)
93+
})
94+
7995
it.each([false, true])(
8096
'puts the field name and validation ARIA on the interactive control (editable=%s)',
8197
(editable) => {

‎packages/emcn/src/components/combobox/combobox.tsx‎

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -790,13 +790,6 @@ const Combobox = memo(
790790
<div className='group relative'>
791791
<Input
792792
ref={inputRef}
793-
className={cn(
794-
'w-full pr-10 transition-colors',
795-
(overlayContent || SelectedIcon) && 'text-transparent caret-foreground',
796-
SelectedIcon && !overlayContent && 'pl-7',
797-
open && 'focus-visible:border-[var(--border-1)]',
798-
className
799-
)}
800793
placeholder={placeholder}
801794
value={value ?? ''}
802795
onChange={handleInputChange}
@@ -810,6 +803,14 @@ const Combobox = memo(
810803
aria-required={ariaRequired}
811804
aria-invalid={ariaInvalid}
812805
{...inputProps}
806+
className={cn(
807+
'w-full pr-10 transition-colors',
808+
(overlayContent || SelectedIcon) && 'text-transparent caret-foreground',
809+
SelectedIcon && !overlayContent && 'pl-7',
810+
open && 'focus-visible:border-[var(--border-1)]',
811+
className,
812+
inputProps?.className
813+
)}
813814
role='combobox'
814815
aria-expanded={open}
815816
aria-haspopup='listbox'

0 commit comments

Comments
 (0)