Skip to content

Commit 60aa6a6

Browse files
fix(orchestrator-form-react): scope async validation to active step (#2602)
* fix(orchestrator-form-react): scope async validation to active step Limit validate:url requests to the active step during multi-step navigation. Made-with: Cursor * fix(orchestrator-form-react): keep full formData for async validation Pass full formData to template evaluation while scoping uiSchema traversal. Made-with: Cursor
1 parent 8e0bb08 commit 60aa6a6

2 files changed

Lines changed: 17 additions & 1 deletion

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@red-hat-developer-hub/backstage-plugin-orchestrator-form-react': patch
3+
---
4+
5+
Scope async validate:url calls to the active step in multi-step forms.

workspaces/orchestrator/plugins/orchestrator-form-react/src/components/OrchestratorFormWrapper.tsx

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,22 @@ const FormComponent = (decoratorProps: FormDecoratorProps) => {
8585
let _extraErrors: ErrorSchema<JsonObject> | undefined = undefined;
8686
let _validationError: Error | undefined = undefined;
8787
const activeKey = getActiveKey();
88+
const shouldScopeExtraErrors =
89+
Boolean(activeKey) && Boolean(uiSchema?.[activeKey as string]);
90+
const extraErrorsFormData = (_formData ?? formData) as JsonObject;
91+
const extraErrorsUiSchema = shouldScopeExtraErrors
92+
? ({
93+
[activeKey as string]: uiSchema?.[activeKey as string],
94+
} as OrchestratorFormContextProps['uiSchema'])
95+
: uiSchema;
8896

8997
if (decoratorProps.getExtraErrors) {
9098
try {
9199
handleValidateStarted();
92-
_extraErrors = await decoratorProps.getExtraErrors(formData, uiSchema);
100+
_extraErrors = await decoratorProps.getExtraErrors(
101+
extraErrorsFormData,
102+
extraErrorsUiSchema,
103+
);
93104

94105
if (activeKey) {
95106
setExtraErrors(

0 commit comments

Comments
 (0)