File tree Expand file tree Collapse file tree 1 file changed +20
-3
lines changed
frontend/src/components/metadata/widgets Expand file tree Collapse file tree 1 file changed +20
-3
lines changed Original file line number Diff line number Diff line change @@ -26,6 +26,25 @@ export const MetadataTextField = (props) => {
2626 const [ readOnly , setReadOnly ] = useState ( initialReadOnly ) ;
2727 const [ inputChanged , setInputChanged ] = useState ( false ) ;
2828
29+ // Get the display value for read-only mode
30+ const getDisplayValue = ( ) => {
31+ if ( ! readOnly ) return null ;
32+
33+ // First check if content has the field
34+ if ( content && content [ fieldName ] !== undefined && content [ fieldName ] !== null ) {
35+ return content [ fieldName ] ;
36+ }
37+
38+ // If not, check if localContent has it (for newly added fields)
39+ if ( localContent && localContent [ fieldName ] !== undefined && localContent [ fieldName ] !== null ) {
40+ return localContent [ fieldName ] ;
41+ }
42+
43+ // If neither has the field, show "null"
44+ return "null" ;
45+ } ;
46+
47+
2948 return (
3049 < Grid container spacing = { 2 } sx = { { alignItems : "center" } } >
3150 < Grid item xs = { 11 } sm = { 11 } md = { 11 } lg = { 11 } xl = { 11 } >
@@ -36,9 +55,7 @@ export const MetadataTextField = (props) => {
3655 fullWidth
3756 name = { widgetName }
3857 required = { isRequired }
39- value = {
40- readOnly && content ? content [ fieldName ] : localContent [ fieldName ]
41- }
58+ value = { getDisplayValue ( ) || "" }
4259 onChange = { ( event : React . ChangeEvent < HTMLInputElement > ) => {
4360 setInputChanged ( true ) ;
4461 const tempContents : { [ key : string ] : string | number } = { } ;
You can’t perform that action at this time.
0 commit comments