diff --git a/src/Form/index.tsx b/src/Form/index.tsx index 067b02ac2..cd4a3020f 100644 --- a/src/Form/index.tsx +++ b/src/Form/index.tsx @@ -1130,6 +1130,16 @@ function Form({ ['fields'] ); + // Call load event before user actions + const oldKey = activeStep?.key ?? ''; + client + .registerEvent({ + step_key: newStep.key, + event: 'load', + previous_step_key: oldKey + }) + .catch(() => {}); + setUserLogicRunning(true); if (!formLoadRan.current) { formLoadRan.current = true; @@ -1163,18 +1173,10 @@ function Form({ props.disabled = props.disabled || disabled; if (servar.required && props.disabled) servar.required = false; }); - const oldKey = activeStep?.key ?? ''; // setActiveStep, apparently, must go after setting the callbackRef // because it triggers a new render, before this fn finishes execution, // which can cause onView to fire before the callbackRef is set setActiveStep(newStep); - client - .registerEvent({ - step_key: newStep.key, - event: 'load', - previous_step_key: oldKey - }) - .catch(() => {}); }; const visiblePositions = useMemo(() => {