File tree 2 files changed +24
-16
lines changed
packages/material-code/src
2 files changed +24
-16
lines changed Original file line number Diff line number Diff line change @@ -55,22 +55,27 @@ export const WidgetCode: React.ComponentType<WidgetProps & WithScalarValue & Wid
55
55
const hideTitle = schema ?. getIn ( [ 'view' , 'hideTitle' ] )
56
56
const readOnly = readOnlyProp || schema ?. get ( 'readOnly' )
57
57
58
- const classNamesContent = React . useMemo ( ( ) => ( valid ? undefined : [ 'invalid' ] ) , [ valid ] )
58
+ const classNamesContent = React . useMemo (
59
+ ( ) => ( ! showValidity || valid ? undefined : [ 'invalid' ] ) ,
60
+ [ valid , showValidity ] ,
61
+ )
59
62
const CodeBarComp = CustomCodeBar || CodeBar
63
+ const showTitle = required || formatValue || ! hideTitle
60
64
return < >
61
- < Box mb = { 0.5 } >
62
- < FormLabel error = { ( ! valid && showValidity ) } >
63
- { hideTitle ? null : < >
64
- < TransTitle storeKeys = { storeKeys } schema = { schema } />
65
- { required ? ' *' : null }
66
- </ > }
67
- { formatValue ? < >
68
- { hideTitle ? null : ' (' }
69
- < Trans text = { 'formats.' + formatValue } fallback = { formatValue } />
70
- { hideTitle ? null : ')' }
71
- </ > : null }
72
- </ FormLabel >
73
- </ Box >
65
+ { showTitle ?
66
+ < Box mb = { 0.5 } >
67
+ < FormLabel error = { ( ! valid && showValidity ) } >
68
+ { hideTitle ? null : < >
69
+ < TransTitle storeKeys = { storeKeys } schema = { schema } />
70
+ { required ? ' *' : null }
71
+ </ > }
72
+ { formatValue ? < >
73
+ { hideTitle ? null : ' (' }
74
+ < Trans text = { 'formats.' + formatValue } fallback = { formatValue } />
75
+ { hideTitle ? null : ')' }
76
+ </ > : null }
77
+ </ FormLabel >
78
+ </ Box > : null }
74
79
75
80
< CodeMirror
76
81
value = { ( value as string ) || '' }
Original file line number Diff line number Diff line change @@ -68,7 +68,10 @@ export const WidgetCodeSelectable: React.ComponentType<WidgetProps & WithScalarV
68
68
const hideTitle = schema ?. getIn ( [ 'view' , 'hideTitle' ] )
69
69
const readOnly = readOnlyProp || schema ?. get ( 'readOnly' )
70
70
71
- const classNamesContent = React . useMemo ( ( ) => ( valid ? undefined : [ 'invalid' ] ) , [ valid ] )
71
+ const classNamesContent = React . useMemo (
72
+ ( ) => ( ! showValidity || valid ? undefined : [ 'invalid' ] ) ,
73
+ [ valid , showValidity ] ,
74
+ )
72
75
const CodeBarComp = CustomCodeBar || CodeBar
73
76
return < >
74
77
{ hideTitle ? null :
@@ -102,7 +105,7 @@ export const WidgetCodeSelectable: React.ComponentType<WidgetProps & WithScalarV
102
105
f =>
103
106
< MenuItem key = { f } value = { f } dense >
104
107
< Trans text = { 'formats.' + f } fallback = { f } />
105
- </ MenuItem >
108
+ </ MenuItem > ,
106
109
) }
107
110
</ Select >
108
111
}
You can’t perform that action at this time.
0 commit comments