Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: support branching in survey preview submit #27623

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

lucasheriques
Copy link
Contributor

@lucasheriques lucasheriques commented Jan 16, 2025

Problem

when previewing surveys, we shouldn't just go to the next question when pressing submit.

instead, use the users' defined logic on branching.

Changes

  • If I set After this question, go to: Next question, go to the next question
  • If it's Confirmation message, go to Confirmation message
  • If it's a specific question, go to that specific question
  • If it's based on answer (most complicated), follow the user defined logic

👉 Stay up-to-date with PostHog coding conventions for a smoother review.

Does this work well for both Cloud and self-hosted?

No impact

How did you test this code?

Tested the feature on localhost

Unit tests

@lucasheriques lucasheriques force-pushed the fix/survey-previews-supports-branching branch from 4cdf5d5 to 1b63b77 Compare January 17, 2025 03:26
@lucasheriques lucasheriques changed the title Submiting a survey in preview mode should redirect to the correct question feat: support branching in survey preview submit Jan 17, 2025
@lucasheriques lucasheriques force-pushed the fix/survey-previews-supports-branching branch from 1b63b77 to 9efaf48 Compare January 17, 2025 03:28
Copy link
Contributor

Size Change: 0 B

Total Size: 1.13 MB

ℹ️ View Unchanged
Filename Size
frontend/dist/toolbar.js 1.13 MB

compressed-size-action

onPreviewSubmit={() => handleSetSelectedPageIndex(previewPageIndex + 1)}
onPreviewSubmit={(response) => {
handleSetSelectedPageIndex(
getNextQuestionIndex(
Copy link
Member

Choose a reason for hiding this comment

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

Since the JS SDK is responsible for rendering the preview and the SDK already knows whats the next question, would be possible to let the JS SDK handle this altogether?

}
}

export function getNextQuestionIndex(
Copy link
Member

Choose a reason for hiding this comment

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

not sure if this is a copy-pasta from the JS SDK, but if not, you could inspire from in case something isn't working well.

@marandaneto marandaneto changed the title feat: support branching in survey preview submit fix: support branching in survey preview submit Jan 17, 2025
@marandaneto
Copy link
Member

Changed the PR title from feat to fix.

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.

2 participants