Skip to content

Conversation

@HarshitVashisht11
Copy link
Contributor

What does this PR do?

Fixes #1289

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • Chore (refactoring code, technical debt, workflow improvements)
  • Enhancement (small improvements)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change adds a new database migration
  • This change requires a documentation update

How should this be tested?

  • Test A
  • Test B

Checklist

Required

  • Filled out the "How to test" section in this PR
  • Read How we Code at Formbricks
  • Self-reviewed my own code
  • Commented on my code in hard-to-understand bits
  • Ran pnpm build
  • Checked for warnings, there are none
  • Removed all console.logs
  • Merged the latest changes from main onto my branch with git pull origin main
  • My changes don't cause any responsiveness issues

Appreciated

  • If a UI change was made: Added a screen recording or screenshots to this PR
  • Updated the Formbricks Docs if changes were necessary

@vercel
Copy link

vercel bot commented Oct 19, 2023

@HarshitVashisht11 is attempting to deploy a commit to the formbricks Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions github-actions bot added bug Something isn't working formtribe-2023 hacktoberfest complete these issues to gather points for Hacktoberfest labels Oct 19, 2023
@github-actions
Copy link
Contributor

github-actions bot commented Oct 19, 2023

Thank you for following the naming conventions for pull request titles! 🙏

@HarshitVashisht11 HarshitVashisht11 changed the title Fix: Disabling Welcome Card leads buggy preview fix: Disabling Welcome Card leads buggy preview Oct 19, 2023
@review-agent-prime
Copy link
Contributor

This PR looks fine with some additional conditions for the QuestionConditional component. However, it seems like there's a possible assumption that could lead to an error in some circumstances.

You're assuming survey?.questions[0] would always exist when questionId === "start" && !survey.welcomeCard.enabled is true and you're directly passing it as props to the QuestionConditional component. If for some reason it doesn't exist, this could potentially lead to runtime errors. To handle that, you might want to consider adding a null check before using it.

) : questionId === "start" && !survey.welcomeCard.enabled && survey?.questions[0] ? (
    <QuestionConditional
      question={survey.questions[0]}
      value={responseData[survey.questions[0]?.id]}
      onChange={onChange}
      onSubmit={onSubmit}
      onBack={onBack}
      isFirstQuestion={
        // if prefillResponseData is provided, check if we're on the first "real" question
        history && prefillResponseData
          ? history[history.length - 1] === survey.questions[0].id
          : true
      }
      isLastQuestion={0 === survey.questions.length - 1}
      brandColor={brandColor}
    />
) : survey.questions.length > 0 ? (
  survey.questions.map(
    (question, idx) => {/* existing logic */}
) : null

In the code above, before rendering QuestionConditional component, I've added an additional check for survey?.questions[0]. If it doesn't exist, fallback mechanism is to execute the existing logic of the original else case if survey question length is greater than zero, else return null. This code ensures checks are performed and won't lead to a potential crash due to missing survey question.

@Dhruwang
Copy link
Member

Hey @HarshitVashisht11 , this looks good 😊🥳

However it would be better if we don't repeat the code for rendering QuestionConditional twice
Can you please find a generic solution for it ?😊

Because we also want to use this fix for thank you card and as per this approach we have to create one more render for QuestionConditional

And can you also create similar fix for thank you card (if disabled, show last question)

Thank you ! 🚀

@HarshitVashisht11
Copy link
Contributor Author

sure i will try

@Dhruwang
Copy link
Member

Hey @HarshitVashisht11 😊 , is it ready for review ?
Because I tested the functionality after pulling the latest changes and it is not working :(
Converting this to draft for now, please mark it as ready for review once its completed 😊

@Dhruwang Dhruwang marked this pull request as draft October 21, 2023 12:14
@HarshitVashisht11
Copy link
Contributor Author

Hi @Dhruwang can tell how to remove thankyou card because i am not able to find option of removing thank you card in the website

@Dhruwang
Copy link
Member

Actually thank you card is mandatory for link surveys but optional for in-app survey (web app), so you will see toggle for it only for in-app surveys
Screenshot 2023-10-21 at 6 00 32 PM

Hope this helps
If you have any other question feel free to reach out 😊

@HarshitVashisht11
Copy link
Contributor Author

HarshitVashisht11 commented Oct 22, 2023

@Dhruwang i can't understand when thank you card is disabled so what will it display when you click on finish

@Dhruwang
Copy link
Member

It should display last question

@HarshitVashisht11
Copy link
Contributor Author

But on last question if someone clicked on finish so why will it show last question

@Dhruwang
Copy link
Member

For link surveys, thank you card is compulsory to after last questions respondent sees the thank you card
But for web app (in-app) surveys, can you create this behaviour 😊
Screenshot 2023-10-22 at 10 40 43 AM

@HarshitVashisht11
Copy link
Contributor Author

Untitled.video.-.Made.with.Clipchamp.1.mp4

@Dhruwang is these changes are good ?

@jobenjada
Copy link
Member

@HarshitVashisht11 The Welcome Card behaviour is good, this works :) People can check out the card but the Preview doesnt break!

On the Thank You card, its not good:

  1. When the Thank You card is disabled, after the last question the web app survey has to go away. In the Survey Editor we have it slide out to the right, reset to the first question and slide back in from the right to indicate that the survey was over.
  2. The Thank You Card should behave exactly like the Welcome Card: When its disabled and people click on it, it should still open but the Preview should not change. You've built it already for the Welcome Card, just apply it to the Thank You card as well.

Thanks!! 🙏

@HarshitVashisht11
Copy link
Contributor Author

Untitled.video.-.Made.with.Clipchamp.2.mp4

I have made the following changes

@HarshitVashisht11
Copy link
Contributor Author

@Dhruwang please review my changes

@Dhruwang Dhruwang marked this pull request as ready for review October 24, 2023 05:43
@vercel
Copy link

vercel bot commented Oct 24, 2023

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

2 Ignored Deployments
Name Status Preview Comments Updated (UTC)
formbricks-cloud ⬜️ Ignored (Inspect) Visit Preview Oct 24, 2023 5:45am
formbricks-com ⬜️ Ignored (Inspect) Visit Preview Oct 24, 2023 5:45am

@Dhruwang
Copy link
Member

Thank you @HarshitVashisht11 for the changes, works good 😊🚀
I just pushed a minor fix for welcome card 😊

@HarshitVashisht11
Copy link
Contributor Author

Hi @Dhruwang Thank you for reviewing my PR, I'm excited to know when my PR might get merged , as hacktoberfest is about to end and I still left 1 more PR.

@jobenjada jobenjada added this pull request to the merge queue Oct 28, 2023
@jobenjada
Copy link
Member

Works well, sorry for the delay and thanks! :)

Merged via the queue into formbricks:main with commit 966dd5f Oct 28, 2023
kevinkong91 added a commit to kevinkong91/formbricks that referenced this pull request Oct 30, 2023
* main: (28 commits)
  chore: Add Table of Contents to README (formbricks#1427)
  fix: account deletion failing issue (formbricks#1509)
  fix: remove welcome card from email preview (formbricks#1495)
  fix(bug): default role implemented (formbricks#1524)
  fix: changing description of Code Action (formbricks#1522)
  refactor: Migrate activity service (formbricks#1471)
  fix: Error in Docs navigation formbricks#1518 (formbricks#1521)
  feat: dynamic title and description (formbricks#1459)
  fix: Spelling Errors (formbricks#1517)
  fix: added scrollbar whenever overflowed in the settings/profile page (formbricks#1498)
  fix: long url not getting reset after closing modal (formbricks#1502)
  fix: Unexpected Behavior when Toggling Italics in Text Editor and improve clarity of formatting status (formbricks#1506)
  fix: zod pin validation failing (formbricks#1507)
  fix: Error message on Login not shown  (formbricks#1508)
  fix: downgrade nextjs to fix error with react email (formbricks#1516)
  chore: downgrade next version in formbricks-com (formbricks#1513)
  feat: picture selection question (formbricks#1388)
  feat: formtribe leaderboard update as per today (formbricks#1505)
  fix: Added if statement for preventing use of reserved word in question ID (formbricks#1435)
  fix: Disabling Welcome Card leads buggy preview (formbricks#1320)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working hacktoberfest complete these issues to gather points for Hacktoberfest hacktoberfest-accepted

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG][FormTribe 🔥][200 Points] Disabling Welcome Card & Thank You card leads to buggy preview

3 participants