Skip to content

Commit 6c34e50

Browse files
committed
fix: use defaultValue only if value is undefined
1 parent a53ff48 commit 6c34e50

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

packages/example/src/controls.stories.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ Controls.args = {
3737
colors: ["Red", "Blue"],
3838
};
3939
Controls.argTypes = {
40+
disabled: {
41+
control: { type: "boolean" },
42+
defaultValue: true,
43+
},
4044
variant: {
4145
options: ["primary", "secondary"],
4246
control: { type: "radio" },

packages/ladle/lib/app/src/args-provider.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,11 @@ const ArgsProvider = ({
107107
name: argValue.name,
108108
type: argValue.control.type,
109109
labels: argValue.control.labels,
110-
defaultValue: args[argKey] ? args[argKey] : argValue.defaultValue,
110+
defaultValue:
111+
args[argKey] === undefined ? argValue.defaultValue : args[argKey],
111112
options: argValue.options,
112-
value: args[argKey] ? args[argKey] : argValue.defaultValue,
113+
value:
114+
args[argKey] === undefined ? argValue.defaultValue : args[argKey],
113115
description: argValue.description || argKey,
114116
min: argValue.control.min,
115117
max: argValue.control.max,

0 commit comments

Comments
 (0)