Skip to content

Commit e922623

Browse files
committed
fix(connectors): drop remembered option labels when the selector context changes
Resolved ids are only meaningful within one selector context, so switching credential, domain, or a dependency has to discard what was remembered under the old one — the queries re-key, but the remembered labels would linger and mislabel until the field remounted. Keyed on the serialized context rather than its identity: the context memo also depends on `sourceConfig`, so its identity changes on unrelated field edits and would clear the cache far more often than intended.
1 parent 63216f9 commit e922623

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

apps/sim/app/workspace/[workspaceId]/knowledge/[id]/components/connector-selector-field/connector-selector-field.tsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,18 @@ export function ConnectorSelectorField({
118118
* trigger showing a raw id for something the user just picked.
119119
*/
120120
const [resolvedOptions, setResolvedOptions] = useState<Record<string, string>>({})
121+
/**
122+
* Ids are only meaningful within one selector context, so switching credential,
123+
* domain, or a dependency must drop what was resolved under the old one — the
124+
* queries re-key, but remembered labels would otherwise linger and mislabel.
125+
* Keyed on the serialized context rather than its identity: the memo also depends
126+
* on `sourceConfig`, so its identity changes on unrelated field edits.
127+
*/
128+
const contextKey = useMemo(() => JSON.stringify(context), [context])
129+
useEffect(() => {
130+
setResolvedOptions((prev) => (Object.keys(prev).length > 0 ? {} : prev))
131+
}, [contextKey])
132+
121133
useEffect(() => {
122134
const found = [searchedOption, selectedOption].filter(Boolean) as SelectorOption[]
123135
if (found.length === 0) return

0 commit comments

Comments
 (0)