fix(InputCreator): show default value in dropdown
This commit is contained in:
@@ -22,7 +22,6 @@ type RawOption = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const optionGenerator = (options: RawOption[]): IFieldDropdownOption[] => options?.map(({ name, value }) => ({ label: name as string, value: value }));
|
const optionGenerator = (options: RawOption[]): IFieldDropdownOption[] => options?.map(({ name, value }) => ({ label: name as string, value: value }));
|
||||||
const getOption = (options: IFieldDropdownOption[], value?: string | boolean) => options?.find(option => option.value === value);
|
|
||||||
|
|
||||||
export default function InputCreator(props: InputCreatorProps): React.ReactElement {
|
export default function InputCreator(props: InputCreatorProps): React.ReactElement {
|
||||||
const {
|
const {
|
||||||
@@ -62,7 +61,7 @@ export default function InputCreator(props: InputCreatorProps): React.ReactEleme
|
|||||||
disableClearable={required}
|
disableClearable={required}
|
||||||
options={preparedOptions}
|
options={preparedOptions}
|
||||||
renderInput={(params) => <MuiTextField {...params} label={label} />}
|
renderInput={(params) => <MuiTextField {...params} label={label} />}
|
||||||
value={getOption(preparedOptions, value)}
|
defaultValue={value as string}
|
||||||
onChange={console.log}
|
onChange={console.log}
|
||||||
description={description}
|
description={description}
|
||||||
loading={loading}
|
loading={loading}
|
||||||
|
Reference in New Issue
Block a user