Skip to content

fix: count only answers on the path the respondent took - #216

Merged
PhilReinking merged 4 commits into
mainfrom
fix/bits-182-answers-on-path
Oct 10, 2026
Merged

PhilReinking merged 4 commits into
mainfrom
fix/bits-182-answers-on-path

Conversation

@PhilReinking

@PhilReinking PhilReinking commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

The public form now sends only answers on the path the respondent really took. Show/hide rules ignore the answer of a hidden or skipped question, and a question a jump skipped no longer sends its answer, also when prefilled.

Fixes BITS-182

  • The store tracks the path. Back follows it: after a jump, Back returns to the question that jumped, not to a skipped one.
  • Show/hide rules read only answers of shown questions above them on the path, so a question can't hide itself.
  • A rule reading a question below it (only possible after a reorder) acts as if that question had no answer.
  • Jumps read the same answers that get sent.
  • Skipped and hidden answers stay in the form: going back and taking that path again shows them.

Heads-up: Back works differently on forms with jumps.

Tested: Vitest, lint and vue-tsc green. The 7 new tests fail on main; the test for forms without rules or jumps passes on both.
Not tested: by hand in a browser.

🤖 Generated with Claude Code

PhilReinking and others added 3 commits October 10, 2026 13:02
Show/hide rules read only answers of shown questions above them, so a
hidden answer counts as none and a question can't hide itself. The store
tracks the path through the form: jumps, back and the sent answers follow
it, and answers of skipped questions stay in the form for a way back.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@PhilReinking PhilReinking left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes at 8f2f166, CI green.

Checked beyond the PR text: on my own server I filled a form with a jump, a group rule, prefill and Back. The stored answers follow the path, Back brings earlier answers back, and a reload starts a new session with the prefill again. With 2000 questions a step takes about 23 ms (14 ms on main). One gap is left, see inline.

Comment thread resources/js/stores/conversation.ts Outdated
continue;
}

if (state.payload[block.id]) {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A question a jump skipped still steers show/hide rules. Example: car = no jumps over brand, and dealer shows when brand = BMW. With ?brand=BMW in the link, or BMW typed before going back, dealer still shows and its answer is stored, but brand isn't. That's the mismatch this ticket fixes for hidden questions.

I'd count only answers on the path here:

const onPath = [...state.path, state.current];
// in the loop
if (state.payload[block.id] && onPath.includes(block.id)) {

I tried it on my own server: dealer is skipped then, and jumps, Back and the group rule still work. Three older tests set payload without path and need the path in their setup. The changelog line could then say that a skipped answer no longer makes later questions show.

A question a jump skipped kept steering show/hide rules with its unsent
answer, also a prefilled one. Rules now count an answer only when its
question is on the path to the current one.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@PhilReinking PhilReinking left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK at 83bdb51, CI green.

The skipped-answer gap is fixed. On my own server, dealer no longer shows or gets stored when brand was skipped, and it still shows when BMW is on the path. A jump to a question that needs a skipped answer falls back to the next question, as for any hidden target, and the stored answers stay consistent.

@PhilReinking
PhilReinking merged commit 635fc89 into main Oct 10, 2026
4 checks passed
@PhilReinking
PhilReinking deleted the fix/bits-182-answers-on-path branch October 10, 2026 12:04
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