summaryrefslogtreecommitdiff
path: root/packages/web-util/src/forms/InputChoiceStacked.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'packages/web-util/src/forms/InputChoiceStacked.tsx')
-rw-r--r--packages/web-util/src/forms/InputChoiceStacked.tsx14
1 files changed, 10 insertions, 4 deletions
diff --git a/packages/web-util/src/forms/InputChoiceStacked.tsx b/packages/web-util/src/forms/InputChoiceStacked.tsx
index 234bb2255..1928f4365 100644
--- a/packages/web-util/src/forms/InputChoiceStacked.tsx
+++ b/packages/web-util/src/forms/InputChoiceStacked.tsx
@@ -3,6 +3,7 @@ import { Fragment, VNode, h } from "preact";
import { UIFormProps } from "./FormProvider.js";
import { LabelWithTooltipMaybeRequired } from "./InputLine.js";
import { useField } from "./useField.js";
+import { noHandlerPropsAndNoContextForField } from "./InputArray.js";
export interface ChoiceS<V> {
label: TranslatedString;
@@ -27,7 +28,12 @@ export function InputChoiceStacked<T extends object, K extends keyof T>(
after,
converter,
} = props;
- const { value, onChange, state, isDirty } = useField<T, K>(name);
+
+ //FIXME: remove deprecated
+ const fieldCtx = useField<T, K>(props.name);
+ const { value, onChange, state } =
+ props.handler ?? fieldCtx ?? noHandlerPropsAndNoContextForField(props.name);
+
if (state.hidden) {
return <Fragment />;
}
@@ -41,7 +47,7 @@ export function InputChoiceStacked<T extends object, K extends keyof T>(
/>
<fieldset class="mt-2">
<div class="space-y-4">
- {choices.map((choice) => {
+ {choices.map((choice, idx) => {
// const currentValue = !converter
// ? choice.value
// : converter.fromStringUI(choice.value) ?? "";
@@ -56,7 +62,7 @@ export function InputChoiceStacked<T extends object, K extends keyof T>(
}
return (
- <label class={clazz}>
+ <label key={idx} class={clazz}>
<input
type="radio"
name="server-size"
@@ -71,7 +77,7 @@ export function InputChoiceStacked<T extends object, K extends keyof T>(
onChange(
(value === choice.value
? undefined
- : choice.value) as T[K],
+ : choice.value) as any,
);
}}
class="sr-only"