OverrideEditor: Use field config default value when adding a new override (#24347)

This commit is contained in:
Torkel Ödegaard 2020-05-06 17:43:34 +02:00 committed by GitHub
parent 66b7398fb6
commit 75ce947267
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -82,14 +82,18 @@ export const OverrideEditor: React.FC<OverrideEditorProps> = ({
const onDynamicConfigValueAdd = useCallback( const onDynamicConfigValueAdd = useCallback(
(id: string) => { (id: string) => {
const registryItem = registry.get(id);
const propertyConfig: DynamicConfigValue = { const propertyConfig: DynamicConfigValue = {
id, id,
value: registryItem.defaultValue,
}; };
if (override.properties) { if (override.properties) {
override.properties.push(propertyConfig); override.properties.push(propertyConfig);
} else { } else {
override.properties = [propertyConfig]; override.properties = [propertyConfig];
} }
onChange(override); onChange(override);
}, },
[override, onChange] [override, onChange]