diff options
author | Sebastian <sebasjm@gmail.com> | 2024-05-03 08:43:53 -0300 |
---|---|---|
committer | Sebastian <sebasjm@gmail.com> | 2024-05-03 08:44:07 -0300 |
commit | 20353eda268efa962959bead466b59823bfb9b29 (patch) | |
tree | 868d016693f09b40e2c55893d3aed72eca505ecb /packages/web-util/src/forms/InputChoiceHorizontal.tsx | |
parent | fa4c7039f4ebeb6ad3cf19237ad7b138519ac142 (diff) | |
download | wallet-core-20353eda268efa962959bead466b59823bfb9b29.tar.xz |
form hook now takes the shape of the form (do not rely on initial value)
Diffstat (limited to 'packages/web-util/src/forms/InputChoiceHorizontal.tsx')
-rw-r--r-- | packages/web-util/src/forms/InputChoiceHorizontal.tsx | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/packages/web-util/src/forms/InputChoiceHorizontal.tsx b/packages/web-util/src/forms/InputChoiceHorizontal.tsx index 82a7c3115..d8361718d 100644 --- a/packages/web-util/src/forms/InputChoiceHorizontal.tsx +++ b/packages/web-util/src/forms/InputChoiceHorizontal.tsx @@ -12,10 +12,10 @@ export interface ChoiceH<V> { export function InputChoiceHorizontal<T extends object, K extends keyof T>( props: { - choices: ChoiceH<T[K]>[]; + choices: ChoiceH<string>[]; } & UIFormProps<T, K>, ): VNode { - const { choices, label, tooltip, help, required } = props; + const { choices, label, tooltip, help, required, converter } = props; //FIXME: remove deprecated const fieldCtx = useField<T, K>(props.name); const { value, onChange, state } = @@ -38,7 +38,7 @@ export function InputChoiceHorizontal<T extends object, K extends keyof T>( const isLast = idx === choices.length - 1; let clazz = "relative inline-flex items-center px-3 py-2 text-sm font-semibold text-gray-900 ring-1 ring-inset ring-gray-300 focus:z-10"; - if (choice.value === value) { + if (converter?.fromStringUI(choice.value as any) === value) { clazz += " text-white bg-indigo-600 hover:bg-indigo-500 ring-2 ring-indigo-600 hover:ring-indigo-500"; } else { @@ -61,7 +61,7 @@ export function InputChoiceHorizontal<T extends object, K extends keyof T>( class={clazz} onClick={(e) => { onChange( - (value === choice.value ? undefined : choice.value) as any, + (value === choice.value ? undefined : converter?.fromStringUI(choice.value as any)) as any, ); }} > |