Skip to content

Commit

Permalink
fix: repopulate struct input fields on relaunch form (#201)
Browse files Browse the repository at this point in the history
Signed-off-by: Pianist038801 <[email protected]>

Co-authored-by: Pianist038801 <[email protected]>
  • Loading branch information
Pianist038801 and Pianist038801 authored Sep 16, 2021
1 parent 9920e0a commit 950e080
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/components/Launch/LaunchForm/StructInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,6 @@ export const StructInput: React.FC<InputProps> = props => {
const hasError = !!error;
const helperText = hasError ? error : props.helperText;

const [paramData, setParamData] = useState({});
const onFormChange = ({ formData }, e) => {
onChange(JSON.stringify(formData));
setParamData(formData);
};

let jsonFormRenderable = false;
let parsedJson: PrimitiveType = {};

Expand All @@ -81,6 +75,15 @@ export const StructInput: React.FC<InputProps> = props => {
}
}

const [paramData, setParamData] = useState(
jsonFormRenderable ? JSON.parse(value as string) : {}
);

const onFormChange = ({ formData }, e) => {
onChange(JSON.stringify(formData));
setParamData(formData);
};

return jsonFormRenderable ? (
<MuiThemeProvider theme={muiTheme}>
<Card>
Expand Down

0 comments on commit 950e080

Please sign in to comment.