Skip to content

Commit 49030d1

Browse files
Copilothuangyiirene
andcommitted
Fix spread order in select/multiselect field helpers
- Extract options from config object to avoid confusion - Change spread order to options first, then finalConfig - Ensures processed options always take precedence Co-authored-by: huangyiirene <7665279+huangyiirene@users.noreply.github.com>
1 parent 95614cd commit 49030d1

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

packages/spec/src/data/field.zod.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -145,10 +145,12 @@ export const Field = {
145145
} else {
146146
// New signature: config object with options
147147
options = (optionsOrConfig.options || []).map(o => typeof o === 'string' ? { label: o, value: o } : o);
148-
finalConfig = optionsOrConfig;
148+
// Remove options from config to avoid confusion
149+
const { options: _, ...restConfig } = optionsOrConfig;
150+
finalConfig = restConfig;
149151
}
150152

151-
return { type: 'select', ...finalConfig, options } as const;
153+
return { type: 'select', options, ...finalConfig } as const;
152154
},
153155

154156
/**
@@ -172,10 +174,12 @@ export const Field = {
172174
} else {
173175
// New signature: config object with options
174176
options = (optionsOrConfig.options || []).map(o => typeof o === 'string' ? { label: o, value: o } : o);
175-
finalConfig = optionsOrConfig;
177+
// Remove options from config to avoid confusion
178+
const { options: _, ...restConfig } = optionsOrConfig;
179+
finalConfig = restConfig;
176180
}
177181

178-
return { type: 'multiselect', ...finalConfig, options } as const;
182+
return { type: 'multiselect', options, ...finalConfig } as const;
179183
},
180184

181185
lookup: (reference: string, config: FieldInput = {}) => ({

0 commit comments

Comments
 (0)