Skip to content

Commit

Permalink
fix: smart marked as false
Browse files Browse the repository at this point in the history
  • Loading branch information
atanasster committed May 13, 2021
1 parent 571f925 commit ac6d2e0
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions core/core/src/controls-utils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
import escape from 'escape-html';
import { deepmerge, deepMergeReplaceArrays } from './deepMerge';
import { deepmerge } from './deepMerge';
import { Components, getComponentName } from './components';
import { Story, Document } from './document';
import { SmartControls } from './common';
Expand Down Expand Up @@ -351,18 +351,22 @@ const controlShortcuts = (
export const transformControls = (
controls?: ComponentControls,
propControls?: ComponentControls,
smart = true,
): ComponentControls | undefined => {
return controls
? Object.keys({ ...propControls, ...controls }).reduce((acc, key) => {
const control = controlShortcuts(key, controls, propControls);
if (control.defaultValue === undefined) {
const defaultValue = getControlValue(control);
if (typeof defaultValue !== 'function') {
control.defaultValue = defaultValue;
? Object.keys(smart ? { ...propControls, ...controls } : controls).reduce(
(acc, key) => {
const control = controlShortcuts(key, controls, propControls);
if (control.defaultValue === undefined) {
const defaultValue = getControlValue(control);
if (typeof defaultValue !== 'function') {
control.defaultValue = defaultValue;
}
}
}
return { ...acc, [key]: control };
}, {})
return { ...acc, [key]: control };
},
{},
)
: undefined;
};

Expand Down Expand Up @@ -445,14 +449,10 @@ export const getStoryControls = (
return true;
})
.reduce((acc, key) => ({ ...acc, [key]: newControls[key] }), {});
const transformed = transformControls(storyControls, filteredControls);
const { smart = true } = smartControls;
if (!story.component || !smart || story.smartControls === false) {
return transformControls(storyControls, filteredControls);
}
return transformed
? deepMergeReplaceArrays(filteredControls, transformed)
: filteredControls;
const isSmart: boolean = story.smartControls !== false && smart;

return transformControls(storyControls, filteredControls, isSmart);
}
}
return transformControls(storyControls);
Expand Down

0 comments on commit ac6d2e0

Please sign in to comment.