Skip to content
Snippets Groups Projects
Commit fb7bd4db authored by Ben Mullins's avatar Ben Mullins
Browse files

Issue #3521213 by bnjmnm, balintbrews: Page data form inputs should not render...

Issue #3521213 by bnjmnm, balintbrews: Page data form inputs should not render until page data exists
parent 53f87c7b
No related branches found
No related tags found
1 merge request!952#3521213 do not render page data inputs until page data is available
Pipeline #482091 failed
......@@ -418,6 +418,11 @@ const InputBehaviorsEntityForm = (
selectFormValues(state, FORM_TYPES.ENTITY_FORM),
);
// Determine if page data is actually available.
// Were we pulling this data *directly* from an API, doing this would be best
// accomplished by the isLoading property provided by RTK. This serves the
// same purpose without adding complexity to our reducers.
const pageDataExists = !!Object.keys(pageData).length;
const { attributes } = props;
const fieldName = attributes.name || attributes['data-xb-name'];
......@@ -479,18 +484,21 @@ const InputBehaviorsEntityForm = (
return { valid: true, errors: null };
};
return (
<InputBehaviorsCommon
key={`${attributes?.name}-${latestUndoRedoActionId}`}
OriginalInput={OriginalInput}
props={props}
callbacks={{
commitFormState: formStateToStore,
parseNewValue,
validateNewValue,
}}
/>
);
if (pageDataExists) {
return (
<InputBehaviorsCommon
key={`${attributes?.name}-${latestUndoRedoActionId}`}
OriginalInput={OriginalInput}
props={props}
callbacks={{
commitFormState: formStateToStore,
parseNewValue,
validateNewValue,
}}
/>
);
}
return <></>;
};
// Provides a higher order component to wrap a form element that will map to
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment