From 409922afb1f61660368f8bc6a61ab37861fda4c6 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Mon, 11 Oct 2021 17:53:51 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Allow=20managed=20`Form.Select`?= =?UTF-8?q?=20and=20`Form.Multiselect`=20to=20have=20selected=20options?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/forms/FormMultiselect.tsx | 4 ++-- src/components/forms/FormSelect.tsx | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/components/forms/FormMultiselect.tsx b/src/components/forms/FormMultiselect.tsx index 5dfd283..7568839 100644 --- a/src/components/forms/FormMultiselect.tsx +++ b/src/components/forms/FormMultiselect.tsx @@ -26,7 +26,7 @@ export interface FormMultiselectProps extends MultiselectProps { } -export function FormMultiselect({label, validity, pairProps, labelProps, onSimpleChange, options, ...props}: FormMultiselectProps): JSX.Element { +export function FormMultiselect({label, validity, pairProps, labelProps, onSimpleChange, options, value, ...props}: FormMultiselectProps): JSX.Element { const onSimpleChangeWrapped = React.useCallback( values => { onSimpleChange?.(values.map((val: string) => options[val])) @@ -35,7 +35,7 @@ export function FormMultiselect({label, validity, pairProps, labelProps, onSimpl ) const optionComponents = React.useMemo( - () => Object.keys(options).map(key => ), + () => Object.keys(options).map(key => ), [options], ) diff --git a/src/components/forms/FormSelect.tsx b/src/components/forms/FormSelect.tsx index 3da509e..0e32b96 100644 --- a/src/components/forms/FormSelect.tsx +++ b/src/components/forms/FormSelect.tsx @@ -26,7 +26,7 @@ export interface FormSelectProps extends SelectProps { } -export function FormSelect({label, validity, options, pairProps, labelProps, onSimpleChange, ...props}: FormSelectProps): JSX.Element { +export function FormSelect({label, validity, options, pairProps, labelProps, onSimpleChange, value, ...props}: FormSelectProps): JSX.Element { const onSimpleChangeWrapped = React.useCallback( value => { onSimpleChange?.(options[value]) @@ -35,7 +35,7 @@ export function FormSelect({label, validity, options, pairProps, labelProps, onS ) const optionComponents = React.useMemo( - () => Object.keys(options).map(key => ), + () => Object.keys(options).map(key => ), [options], )