Skip to content

Commit

Permalink
fix: reset values on smart controls
Browse files Browse the repository at this point in the history
  • Loading branch information
atanasster committed Jul 31, 2020
1 parent ecd6aec commit 30dfba3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
14 changes: 10 additions & 4 deletions core/core/src/controls-smart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) => ({
Expand Down
1 change: 0 additions & 1 deletion ui/blocks/src/PropsTable/BasePropsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,6 @@ export const BasePropsTable: FC<BasePropsTableProps> = ({
value: any,
) => {
setControlValue(value);
console.log(storyId, propertyName, value);
},
}),
);
Expand Down

0 comments on commit 30dfba3

Please sign in to comment.