Skip to content

Commit 3c86c88

Browse files
committed
Always show labels on dynamic props
1 parent 9b478e3 commit 3c86c88

File tree

3 files changed

+14
-15
lines changed

3 files changed

+14
-15
lines changed

packages/connect-react/src/components/ControlSelect.tsx

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -171,26 +171,16 @@ export function ControlSelect<T>({
171171
if (o) {
172172
if (Array.isArray(o)) {
173173
if (typeof o[0] === "object" && "value" in o[0]) {
174-
const vs = [];
175-
for (const _o of o) {
176-
if (prop.withLabel) {
177-
vs.push(_o);
178-
} else {
179-
vs.push(_o.value);
180-
}
181-
}
182-
onChange(vs);
183-
} else {
184-
onChange(o);
185-
}
186-
} else if (typeof o === "object" && "value" in o) {
187-
if (prop.withLabel) {
188174
onChange({
189175
__lv: o,
190176
});
191177
} else {
192-
onChange(o.value);
178+
onChange(o);
193179
}
180+
} else if (typeof o === "object" && "value" in o) {
181+
onChange({
182+
__lv: o,
183+
});
194184
} else {
195185
throw new Error("unhandled option type"); // TODO
196186
}

packages/connect-react/src/hooks/form-context.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,12 @@ export const FormContextProvider = <T extends ConfigurableProps>({
254254
setErrors(_errors);
255255
};
256256

257+
useEffect(() => {
258+
updateConfiguredPropsQueryDisabledIdx(_configuredProps)
259+
}, [
260+
_configuredProps,
261+
]);
262+
257263
useEffect(() => {
258264
const newConfiguredProps: ConfiguredProps<T> = {};
259265
for (const prop of configurableProps) {

packages/connect-react/src/utils/component.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ export function valuesFromOptions<T>(value: unknown | T[] | PropOptions<T>): T[]
4040
}
4141
return results
4242
}
43+
if (value && typeof value === "object" && "__lv" in value && Array.isArray(value.__lv)) {
44+
return value.__lv as T[]
45+
}
4346
if (!Array.isArray(value))
4447
return []
4548
return value as T[]

0 commit comments

Comments
 (0)