From 017a8814944575afd37fa0616377cb248a3d75e2 Mon Sep 17 00:00:00 2001 From: kattoczko <50657366+kattoczko@users.noreply.github.com> Date: Thu, 20 Jun 2024 11:13:45 +0200 Subject: [PATCH] feat: persist parameters values in FlowSubstep (#1505) * feat: persist parameters values in FlowSubstep * feat: add missing import * feat: use usePrevious hook --- .../web/src/components/FlowSubstep/index.jsx | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/packages/web/src/components/FlowSubstep/index.jsx b/packages/web/src/components/FlowSubstep/index.jsx index 55bb5cd6..69810db7 100644 --- a/packages/web/src/components/FlowSubstep/index.jsx +++ b/packages/web/src/components/FlowSubstep/index.jsx @@ -5,11 +5,13 @@ import Collapse from '@mui/material/Collapse'; import ListItem from '@mui/material/ListItem'; import Button from '@mui/material/Button'; import Stack from '@mui/material/Stack'; +import isEqual from 'lodash/isEqual'; import { EditorContext } from 'contexts/Editor'; import FlowSubstepTitle from 'components/FlowSubstepTitle'; import InputCreator from 'components/InputCreator'; import FilterConditions from './FilterConditions'; import { StepPropType, SubstepPropType } from 'propTypes/propTypes'; +import { usePrevious } from 'hooks/usePrevious'; function FlowSubstep(props) { const { @@ -19,13 +21,27 @@ function FlowSubstep(props) { onCollapse, onSubmit, step, + onChange, } = props; + + const prevStep = usePrevious(step); + const { name, arguments: args } = substep; const editorContext = React.useContext(EditorContext); const formContext = useFormContext(); const validationStatus = formContext.formState.isValid; const onToggle = expanded ? onCollapse : onExpand; + React.useEffect(() => { + return () => { + if (!isEqual(prevStep?.parameters, formContext.getValues('parameters'))) { + onChange({ + step: { ...step, parameters: formContext.getValues('parameters') }, + }); + } + }; + }, []); + return (