mirror of
https://github.com/soconnor0919/hristudio.git
synced 2026-05-08 05:48:56 -04:00
fix(wizard): skip unchosen branch steps during linear progression
When the wizard makes a branch choice, mark all other branch targets as skipped. Linear progression now advances past skipped steps, so path 1→2→4 no longer executes step 3 when branch A was chosen. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -792,8 +792,11 @@ export const WizardInterface = React.memo(function WizardInterface({
|
||||
);
|
||||
}
|
||||
|
||||
// Default: Linear progression
|
||||
const nextIndex = currentStepIndex + 1;
|
||||
// Default: Linear progression (skip steps marked as skipped by branching)
|
||||
let nextIndex = currentStepIndex + 1;
|
||||
while (nextIndex < steps.length && skippedSteps.has(nextIndex)) {
|
||||
nextIndex++;
|
||||
}
|
||||
if (nextIndex < steps.length) {
|
||||
// Mark current step as complete
|
||||
setCompletedSteps((prev) => {
|
||||
@@ -942,6 +945,24 @@ export const WizardInterface = React.memo(function WizardInterface({
|
||||
console.log(
|
||||
`[WizardInterface] Choice-based jump to step ${targetIndex} (${nextId})`,
|
||||
);
|
||||
|
||||
// Mark other branch targets as skipped so linear progression bypasses them
|
||||
const branchingStep = steps[currentStepIndex];
|
||||
const allOptions =
|
||||
(branchingStep?.conditions?.options as any[]) ?? [];
|
||||
setSkippedSteps((prev) => {
|
||||
const next = new Set(prev);
|
||||
for (const opt of allOptions) {
|
||||
if (opt.nextStepId && opt.nextStepId !== nextId) {
|
||||
const otherIdx = steps.findIndex(
|
||||
(s) => s.id === opt.nextStepId,
|
||||
);
|
||||
if (otherIdx !== -1) next.add(otherIdx);
|
||||
}
|
||||
}
|
||||
return next;
|
||||
});
|
||||
|
||||
handleNextStep(targetIndex);
|
||||
return; // Exit after jump
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user