fix(widget-number): allow zero as value (#2261)
This commit is contained in:
parent
9e08b65502
commit
800c3ee1a4
@ -100,7 +100,7 @@ export default class NumberControl extends React.Component {
|
|||||||
className={classNameWrapper}
|
className={classNameWrapper}
|
||||||
onFocus={setActiveStyle}
|
onFocus={setActiveStyle}
|
||||||
onBlur={setInactiveStyle}
|
onBlur={setInactiveStyle}
|
||||||
value={value || ''}
|
value={value || (value === 0 ? value : '')}
|
||||||
step={step}
|
step={step}
|
||||||
min={min}
|
min={min}
|
||||||
max={max}
|
max={max}
|
||||||
|
@ -119,4 +119,15 @@ describe('Number widget', () => {
|
|||||||
expect(onChangeSpy).toHaveBeenCalledTimes(1);
|
expect(onChangeSpy).toHaveBeenCalledTimes(1);
|
||||||
expect(onChangeSpy).toHaveBeenCalledWith(parseInt(testValue, 10));
|
expect(onChangeSpy).toHaveBeenCalledWith(parseInt(testValue, 10));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should allow 0 as a value', () => {
|
||||||
|
const field = fromJS(fieldSettings);
|
||||||
|
const testValue = 0;
|
||||||
|
const { input } = setup({ field });
|
||||||
|
|
||||||
|
fireEvent.focus(input);
|
||||||
|
fireEvent.change(input, { target: { value: String(testValue) } });
|
||||||
|
|
||||||
|
expect(input.value).toBe('0');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user