mirror of
https://github.com/storybookjs/storybook.git
synced 2025-04-04 16:11:08 +08:00
Fix null handling
This commit is contained in:
parent
c3e79d4c0a
commit
e13c905ae5
@ -38,7 +38,8 @@ export const NumberControl: FC<NumberProps> = ({
|
||||
onChange={handleChange}
|
||||
size="flex"
|
||||
placeholder="Adjust number dynamically"
|
||||
{...{ name, value, min, max, step, onFocus, onBlur }}
|
||||
value={value === null ? undefined : value}
|
||||
{...{ name, min, max, step, onFocus, onBlur }}
|
||||
/>
|
||||
</Wrapper>
|
||||
);
|
||||
|
@ -229,8 +229,8 @@ const getCustomStyleFunction: (theme: Theme) => JsonTreeProps['getStyle'] = (the
|
||||
},
|
||||
});
|
||||
|
||||
export const ObjectControl: React.FC<ObjectProps> = ({ name, value = {}, onChange }) => {
|
||||
const data = useMemo(() => cloneDeep(value), [value]);
|
||||
export const ObjectControl: React.FC<ObjectProps> = ({ name, value, onChange }) => {
|
||||
const data = useMemo(() => value && cloneDeep(value), [value]);
|
||||
const [showRaw, setShowRaw] = useState(false);
|
||||
const [parseError, setParseError] = useState();
|
||||
const updateRaw = useCallback(
|
||||
@ -248,7 +248,7 @@ export const ObjectControl: React.FC<ObjectProps> = ({ name, value = {}, onChang
|
||||
<RawInput
|
||||
id={name}
|
||||
name={name}
|
||||
defaultValue={JSON.stringify(value, null, 2)}
|
||||
defaultValue={value === null ? '' : JSON.stringify(value, null, 2)}
|
||||
onBlur={(event) => updateRaw(event.target.value)}
|
||||
placeholder="Enter JSON string"
|
||||
valid={parseError ? 'error' : null}
|
||||
|
Loading…
x
Reference in New Issue
Block a user