fix: remove empty else-if branches and add numbering (#17315)

This commit is contained in:
Abdul Rahman
2026-01-22 20:00:11 +05:30
committed by GitHub
parent 235fc44228
commit 4ccdbf1150
10 changed files with 87 additions and 9 deletions
@@ -104,21 +104,46 @@ export const removeStep = ({
});
}
const finalNextStepIds = updatedNextStepIds.filter(
(id) => !allRemovedStepIds.includes(id),
);
return {
...branch,
nextStepIds: updatedNextStepIds.filter(
(id) => !allRemovedStepIds.includes(id),
),
nextStepIds: finalNextStepIds,
};
});
const filteredBranches = updatedBranches.filter(
(branch, branchIndex) => {
const isIfBranch = branchIndex === 0;
const isElseBranch =
branchIndex === updatedBranches.length - 1 &&
!isDefined(branch.filterGroupId);
const isElseIfBranch =
branchIndex > 0 &&
branchIndex < updatedBranches.length - 1 &&
isDefined(branch.filterGroupId);
if (isIfBranch || isElseBranch) {
return true;
}
if (isElseIfBranch && branch.nextStepIds.length === 0) {
return false;
}
return true;
},
);
return {
...step,
settings: {
...step.settings,
input: {
...step.settings.input,
branches: updatedBranches,
branches: filteredBranches,
},
},
};