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(surveys): use correct render method #1157

Merged
merged 1 commit into from
Apr 29, 2024
Merged

fix(surveys): use correct render method #1157

merged 1 commit into from
Apr 29, 2024

Conversation

jurajmajerik
Copy link
Contributor

@jurajmajerik jurajmajerik commented Apr 26, 2024

Problem

In PostHog/posthog#20321, surveys are rendered using preact-render-to-string. This method renders plain HTML, stripping any event listeners. Because of this, some interactions were not working (I had missed this in the initial review - my bad).

Changes

  • Switch to Preact.render for rendering previews
  • Some minor adjustments to render the Thank you message

This needs a much bigger cleanup, but annoying to do with the current slow iteration cycle - want to set up a better environment first. But this will get us over the line with PostHog/posthog#20321

This change should be merged together with PostHog/posthog#20321

Test

Screen.Recording.2024-04-26.at.12.14.54.mov

Checklist

  • Tests for new code (see advice on the tests we use)
  • Accounted for the impact of any changes across different browsers
  • Accounted for backwards compatibility of any changes (no breaking changes in posthog-js!)

Copy link

vercel bot commented Apr 26, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
posthog-js ✅ Ready (Inspect) Visit Preview Apr 26, 2024 10:17am

Copy link

Size Change: -4.35 kB (0%)

Total Size: 971 kB

Filename Size Change
dist/surveys-module-previews.js 57.2 kB -4.86 kB (-8%)
dist/surveys.js 58.8 kB +509 B (+1%)
ℹ️ View Unchanged
Filename Size
dist/array.full.js 233 kB
dist/array.js 131 kB
dist/es.js 131 kB
dist/exception-autocapture.js 12.2 kB
dist/module.js 131 kB
dist/recorder-v2.js 108 kB
dist/recorder.js 108 kB

compressed-size-action

Copy link
Collaborator

@benjackwhite benjackwhite left a comment

Choose a reason for hiding this comment

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

This makes total sense.

@neilkakkar
Copy link
Collaborator

Makes sense 👍 .

Heads up for the companion PR / cleanup, that the margins are off:
image

@neilkakkar neilkakkar added the bump patch Bump patch version when this PR gets merged label Apr 26, 2024
@@ -320,40 +315,66 @@ export function Questions({
setCurrentQuestion(idx + 1)
}
}
const isMultipleQuestion = survey.questions.length > 1

const questionToDisplay = readOnly ? previewQuestionIndex : currentQuestion
Copy link
Collaborator

Choose a reason for hiding this comment

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

A bit annoying that in the main code we have to have special handling for previews, I expect this will become a lot more annoying when you need actual functionality with the branching logic for example.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

💯 , I want to clean this up

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bump patch Bump patch version when this PR gets merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants