From 30dfba3d1b87fb7ed3e816f91dc371ea5c47196d Mon Sep 17 00:00:00 2001 From: atanasster Date: Fri, 31 Jul 2020 05:18:16 -0400 Subject: [PATCH] fix: reset values on smart controls --- core/core/src/controls-smart.ts | 14 ++++++++++---- ui/blocks/src/PropsTable/BasePropsTable.tsx | 1 - 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/core/core/src/controls-smart.ts b/core/core/src/controls-smart.ts index 22ff742ac..c95b4becc 100644 --- a/core/core/src/controls-smart.ts +++ b/core/core/src/controls-smart.ts @@ -144,10 +144,16 @@ interface NamedComponentControl { } export const controlsFromProps = (props: PropTypes): ComponentControls => { return Object.keys(props) - .map((key: string) => ({ - name: key, - control: controlFromProps(key, props[key]), - })) + .map((key: string) => { + const control = controlFromProps(key, props[key]); + if (control) { + control.defaultValue = control.value; + } + return { + name: key, + control, + }; + }) .filter(p => p.control) .reduce( (acc: ComponentControls, prop: NamedComponentControl) => ({ diff --git a/ui/blocks/src/PropsTable/BasePropsTable.tsx b/ui/blocks/src/PropsTable/BasePropsTable.tsx index 6a994b04c..91a9d8641 100644 --- a/ui/blocks/src/PropsTable/BasePropsTable.tsx +++ b/ui/blocks/src/PropsTable/BasePropsTable.tsx @@ -331,7 +331,6 @@ export const BasePropsTable: FC = ({ value: any, ) => { setControlValue(value); - console.log(storyId, propertyName, value); }, }), );