Skip to content

fix: branching forms with visibilityCriteria render the hidden next step#477

Merged
christianmat merged 1 commit intomainfrom
fix/branching-visibility-criteria
Apr 30, 2026
Merged

fix: branching forms with visibilityCriteria render the hidden next step#477
christianmat merged 1 commit intomainfrom
fix/branching-visibility-criteria

Conversation

@christianmat
Copy link
Copy Markdown
Contributor

Summary

  • Fixes a bug where branching forms with visibilityCriteria depending on the just-submitted step's form data would still render the now-hidden next step instead of skipping past it. Reported by a customer on flow_dVcRW58i (docs example for branching forms).
  • Root cause: in internalComplete (packages/js-api/src/core/flow.ts), after the COMPLETED_STEP/SKIPPED_STEP response refreshed state, the client fired a follow-up STARTED_STEP for the optimistic next step (chosen from pre-request visibility). When the server hid that step via visibilityCriteria after seeing the form data, the spurious STARTED_STEP flipped currentStepId back to the now-hidden step. Verified by replaying the API sequence against prod with the customer's flow.
  • Fix: after the refresh, derive the next-step event from this.getCurrentStep() rather than the pre-request nextStepForStartEvent. The non-branching behavior added in 2723c81 is preserved (the new regression test guards it).
  • Changeset bumps both @frigade/js and @frigade/react as patches so customers pick up the fix on a normal yarn upgrade @frigade/react.

Test plan

  • New failing test in packages/js-api/test/flow-branching-visibility.test.ts reproduces the bug, then passes after the fix.
  • New regression test verifies non-branching flows still send STARTED_STEP for the next step (preserves 2723c81).
  • yarn test in packages/js-api: 28 passed, 0 failed (existing flow-flicker and integration tests unaffected).
  • Manually verify in Storybook against the customer's flow that picking "Go to page 3" lands on page 3 (already verified locally pre-PR).

🤖 Generated with Claude Code

internalComplete computed the next step optimistically from
pre-request visibility, then fired STARTED_STEP for it after the
COMPLETED_STEP/SKIPPED_STEP response refreshed state. In branching
forms whose visibilityCriteria depends on the just-submitted form
data, the optimistic next step could be hidden by the server, and
the STARTED_STEP would clobber currentStepId back to the now-hidden
step — leaving the user stuck on a step that should have been skipped.

Now derive the next-step event from this.getCurrentStep() after the
refresh so we notify the server about the actual current step. The
non-branching behavior added in 2723c81 is preserved (covered by a
new regression test).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@christianmat christianmat merged commit 9bbb311 into main Apr 30, 2026
0 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant