Skip to content

Commit

Permalink
Merge 550fe09 into fce6b1e
Browse files Browse the repository at this point in the history
  • Loading branch information
adammation committed Jan 11, 2024
2 parents fce6b1e + 550fe09 commit a012752
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/vanilla-renderers/src/cells/TextCell.tsx
Expand Up @@ -50,7 +50,9 @@ export const TextCell = (props: CellProps & VanillaRendererProps) => {
const appliedUiSchemaOptions = merge({}, config, uischema.options);
return (
<input
type='text'
type={
appliedUiSchemaOptions.format ? appliedUiSchemaOptions.format : 'text'
}
value={data || ''}
onChange={(ev) =>
handleChange(path, ev.target.value === '' ? undefined : ev.target.value)
Expand Down
33 changes: 33 additions & 0 deletions packages/vanilla-renderers/test/renderers/TextCell.test.tsx
Expand Up @@ -593,4 +593,37 @@ describe('Text cell', () => {
expect(input.maxLength).toBe(defaultMaxLength);
expect(input.size).toBe(defaultSize);
});

test('default type is text', () => {
const uischema: ControlElement = {
type: 'Control',
scope: '#/properties/name',
};
const core = initCore(fixture.schema, uischema, fixture.data);
wrapper = mount(
<JsonFormsStateProvider initState={{ core }}>
<TextCell schema={fixture.schema} uischema={uischema} path='name' />
</JsonFormsStateProvider>
);
const input = wrapper.find('input').getDOMNode() as HTMLInputElement;
expect(input.type).toBe('text');
});

test('change type to password', () => {
const uischema: ControlElement = {
type: 'Control',
scope: '#/properties/name',
options: {
format: 'password',
},
};
const core = initCore(fixture.schema, uischema, fixture.data);
wrapper = mount(
<JsonFormsStateProvider initState={{ core }}>
<TextCell schema={fixture.schema} uischema={uischema} path='name' />
</JsonFormsStateProvider>
);
const input = wrapper.find('input').getDOMNode() as HTMLInputElement;
expect(input.type).toBe('password');
});
});

0 comments on commit a012752

Please sign in to comment.