Skip to content

Commit

Permalink
fix: switch to correct object on rule output type change
Browse files Browse the repository at this point in the history
  • Loading branch information
tomcur committed Feb 14, 2024
1 parent 257222b commit 6c57c0b
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/scenes/kit/kit-data/configure/Rules/components/EditOutput.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useState, useRef } from "react";
import React, { useState, useRef, useEffect } from "react";
import compose from "~/utils/compose";
import { withTranslation, WithTranslation } from "react-i18next";
import { Icon } from "semantic-ui-react";
Expand Down Expand Up @@ -58,7 +58,7 @@ function EditOutput(props: PInner) {

let outputSettingsSchemaModified: JSONSchema7;
let outputSettingsUiSchema: any;
let data: any;
let data: object | undefined;
if (outputType === "continuous") {
outputSettingsSchemaModified = produce(
castDraft(continuousOutputSettingsSchema),
Expand Down Expand Up @@ -93,6 +93,14 @@ function EditOutput(props: PInner) {
}
const [formData, setFormData] = useState(data);

useEffect(
() => setFormData(data),
[
outputType, // note: the outputType dependency is necessary here to ensure formData updates on outputType change
data,
],
);

const submitButtonRef = useRef(null);

const handleClose = () => {
Expand Down

0 comments on commit 6c57c0b

Please sign in to comment.