Skip to content

Commit 3a68d0c

Browse files
authored
fix: consistently use outlined input variant in React Material
Use outlined input variant as the default to align with Material UI
1 parent 1791e5c commit 3a68d0c

File tree

3 files changed

+42
-4
lines changed

3 files changed

+42
-4
lines changed

MIGRATION.md

+38
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,43 @@
11
# Migration guide
22

3+
## Migrating to JSON Forms 3.2
4+
5+
### Material Renderers using Outlined Inputs
6+
7+
JSON Forms now uses the `outlined` input variant as the default, aligning with the default style of Material UI since version 5.
8+
If you would like to use the `standard` input variant, as was default in previous versions of JSON Forms, then this can be accomplished using the Material UI `ThemeProvider`:
9+
10+
```ts
11+
import { JsonForms } from '@jsonforms/react';
12+
import { createTheme, ThemeProvider } from '@mui/material/styles';
13+
14+
const theme = createTheme({
15+
components: {
16+
MuiFormControl: {
17+
defaultProps: {
18+
variant: 'standard',
19+
},
20+
},
21+
MuiTextField: {
22+
defaultProps: {
23+
variant: 'standard',
24+
},
25+
},
26+
MuiSelect: {
27+
defaultProps: {
28+
variant: 'standard',
29+
},
30+
},
31+
},
32+
});
33+
34+
...
35+
36+
<ThemeProvider theme={theme}>
37+
<JsonForms {...props} />
38+
</ThemeProvider>;
39+
```
40+
341
## Migrating to JSON Forms 3.0
442

543
### Additional parameter for testers

packages/material-renderers/src/util/theme.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ const variantToInput = {
5252
outlined: OutlinedInput,
5353
};
5454

55-
export const defaultInputVariant: TextFieldProps['variant'] = 'standard';
55+
export const defaultInputVariant: TextFieldProps['variant'] = 'outlined';
5656

5757
export function useInputVariant(): TextFieldProps['variant'] {
5858
const { variant = defaultInputVariant } = useThemeProps({

packages/material-renderers/test/renderers/MaterialTextControl.test.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import { MaterialInputControl } from '../../src/controls/MaterialInputControl';
3030
import { MuiInputText } from '../../src/mui-controls/MuiInputText';
3131
import Adapter from '@wojtekmaj/enzyme-adapter-react-17';
3232
import { ControlElement, ControlProps } from '@jsonforms/core';
33-
import { Input, InputAdornment } from '@mui/material';
33+
import { InputAdornment, OutlinedInput } from '@mui/material';
3434

3535
Enzyme.configure({ adapter: new Adapter() });
3636

@@ -99,7 +99,7 @@ describe('Material text control', () => {
9999
const props = defaultControlProps();
100100
wrapper = mount(createMaterialTextControl(props));
101101
// call onPointerEnter prop manually as the tests seem to ignore 'pointerenter' events, 'mouseover' events work however.
102-
wrapper.find(Input).props().onPointerEnter?.call(this);
102+
wrapper.find(OutlinedInput).props().onPointerEnter?.call(this);
103103
wrapper.update();
104104
expect(wrapper.find(InputAdornment).props().style).not.toHaveProperty(
105105
'display',
@@ -112,7 +112,7 @@ describe('Material text control', () => {
112112
delete props.data;
113113
wrapper = mount(createMaterialTextControl(props));
114114
// call onPointerEnter prop manually as the tests seem to ignore 'pointerenter' events, 'mouseover' events work however.
115-
wrapper.find(Input).props().onPointerEnter?.call(this);
115+
wrapper.find(OutlinedInput).props().onPointerEnter?.call(this);
116116
wrapper.update();
117117
expect(wrapper.find(InputAdornment).props().style).toHaveProperty(
118118
'display',

0 commit comments

Comments
 (0)