Skip to content

Commit 02a3a24

Browse files
committed
fix - we could not edit value
1 parent 61dec97 commit 02a3a24

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

frontend/src/components/metadata/widgets/MetadataTextField.tsx

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,23 @@ export const MetadataTextField = (props) => {
4444
return "null";
4545
};
4646

47+
// Get the value for the text field
48+
const getValue = () => {
49+
if (readOnly) {
50+
// Read-only mode: show content or "null"
51+
if (content && content[fieldName] !== undefined && content[fieldName] !== null) {
52+
return content[fieldName];
53+
}
54+
if (localContent && localContent[fieldName] !== undefined && localContent[fieldName] !== null) {
55+
return localContent[fieldName];
56+
}
57+
return "null";
58+
} else {
59+
// Edit mode: show localContent value (what user is typing)
60+
return localContent[fieldName] || "";
61+
}
62+
};
63+
4764

4865
return (
4966
<Grid container spacing={2} sx={{ alignItems: "center" }}>
@@ -55,7 +72,7 @@ export const MetadataTextField = (props) => {
5572
fullWidth
5673
name={widgetName}
5774
required={isRequired}
58-
value={getDisplayValue() || ""}
75+
value={getValue()}
5976
onChange={(event: React.ChangeEvent<HTMLInputElement>) => {
6077
setInputChanged(true);
6178
const tempContents: { [key: string]: string | number } = {};

0 commit comments

Comments
 (0)