Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ In this case, you can try to clean the repository with `git clean -dfx`. Beware
- Build (all packages): `pnpm run build`
- Test (all packages): `pnpm run test`
- Clean (delete `dist` folder of all packages): `pnpm run clean`
- Run React Vanilla examples: `cd packages/vanilla && pnpm run dev`
- Run React Material examples: `cd packages/material && pnpm run dev`
- Run React Vanilla examples: `cd packages/vanilla-renderers && pnpm run dev`
- Run React Material examples: `cd packages/material-renderers && pnpm run dev`
- Run Angular Material examples: `cd packages/angular-material && pnpm run dev`
- Run Vue Vanilla dev setup: `cd packages/vue-vanilla && pnpm run serve`

Expand Down
10 changes: 7 additions & 3 deletions packages/material-renderers/src/controls/MaterialRadioGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ export const MaterialRadioGroup = (props: ControlProps & OwnPropsOfEnum) => {
focused,
appliedUiSchemaOptions.showUnfocusedDescription
);
const onChange = (_ev: any, value: any) => handleChange(path, value);

return (
<Hidden xsUp={!visible}>
Expand All @@ -87,12 +86,17 @@ export const MaterialRadioGroup = (props: ControlProps & OwnPropsOfEnum) => {
{label}
</FormLabel>

<RadioGroup value={props.data ?? ''} onChange={onChange} row={true}>
<RadioGroup value={props.data ?? ''} row={true}>
{options.map((option) => (
<FormControlLabel
value={option.value}
key={option.label}
control={<Radio checked={data === option.value} />}
control={
<Radio
checked={data === option.value}
onChange={() => handleChange(path, option.value)}
/>
}
label={option.label}
disabled={!enabled}
/>
Expand Down
2 changes: 1 addition & 1 deletion packages/vanilla-renderers/rollup.example.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import typescript from 'rollup-plugin-typescript2';
* @type {import('rollup').RollupOptions}
*/
const config = {
input: 'example/index.ts',
input: 'example/index.tsx',
output: {
file: 'example/dist/bundle.js',
format: 'iife',
Expand Down
2 changes: 1 addition & 1 deletion packages/vanilla-renderers/src/controls/RadioGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ export const RadioGroup = ({
id={option.value}
name={id}
checked={data === option.value}
onChange={(ev) => handleChange(path, ev.currentTarget.value)}
onChange={(_) => handleChange(path, option.value)}
disabled={!enabled}
className={radioInput}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,4 +215,43 @@ describe('Radio group control', () => {
expect(currentlyChecked).toHaveLength(1);
expect((currentlyChecked.getDOMNode() as HTMLInputElement).value).toBe('B');
});

test('Radio group should preserve option type', () => {
const renderers = [
{ tester: rankWith(10, isEnumControl), renderer: RadioGroupControl },
];
const schema = {
type: 'object',
properties: {
amount: {
type: 'integer',
enum: [50, 100, 250, 500],
},
},
};
const uischema = {
type: 'Control',
scope: '#/properties/amount',
options: {
format: 'radio',
},
};
const core = initCore(schema, uischema, fixture.data);
wrapper = mount(
<JsonFormsStateProvider initState={{ core, renderers }}>
<RadioGroupControl schema={schema} uischema={uischema} />
</JsonFormsStateProvider>
);

// Simulate a click event to change the selection
const radioInput = wrapper.find('input[value=100]');
radioInput.simulate('change');

const currentlyChecked = wrapper.find('input[checked=true]');
expect(currentlyChecked).toHaveLength(1);

// Check the type of the selected radio element's value
const selectedValue = currentlyChecked.props().value;
expect(typeof selectedValue).toBe('number');
});
});