Skip to content

Commit 23e1a55

Browse files
authored
Fix React Vanilla IntegerCell not rendering zero
The React Vanilla IntegerCell now correctly displays the number 0 instead of an empty string.
1 parent 7e5ac13 commit 23e1a55

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

packages/vanilla/src/cells/IntegerCell.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export const IntegerCell = (props: CellProps & VanillaRendererProps) => {
4040
<input
4141
type='number'
4242
step='1'
43-
value={data || ''}
43+
value={data ?? ''}
4444
onChange={ev => handleChange(path, parseInt(ev.target.value, 10))}
4545
className={className}
4646
id={id}

packages/vanilla/test/renderers/IntegerCell.test.tsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,4 +351,15 @@ describe('Integer cell', () => {
351351
const input = wrapper.find('input').getDOMNode() as HTMLInputElement;
352352
expect(input.disabled).toBe(false);
353353
});
354+
355+
test('shows 0 instead of empty string', () => {
356+
const core = initCore(fixture.schema, fixture.uischema, { foo: 0 });
357+
wrapper = mount(
358+
<JsonFormsStateProvider initState={{ core }}>
359+
<IntegerCell schema={fixture.schema} uischema={fixture.uischema} path='foo' />
360+
</JsonFormsStateProvider>
361+
);
362+
const input = wrapper.find('input').getDOMNode() as HTMLInputElement;
363+
expect(input.value).toBe('0');
364+
});
354365
});

0 commit comments

Comments
 (0)