Skip to content

fix: resposiveness issue in the survey's hidden fields#3952

Merged
jobenjada merged 2 commits intoformbricks:mainfrom
DivyanshuLohani:fix-elememts-resposiveness-issue-#3882
Oct 23, 2024
Merged

fix: resposiveness issue in the survey's hidden fields#3952
jobenjada merged 2 commits intoformbricks:mainfrom
DivyanshuLohani:fix-elememts-resposiveness-issue-#3882

Conversation

@DivyanshuLohani
Copy link
Contributor

@DivyanshuLohani DivyanshuLohani commented Oct 21, 2024

What does this PR do?

Fixes the responsiveness bug in the hidden fields card on the survey edit/create page
Fixes #3882
image

How should this be tested?

  • Create a new Survey
  • Open the hidden fields card
  • Add fields

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
  • First PR at Formbricks? Please sign the CLA! Without it we wont be able to merge it 🙏

Appreciated

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

Summary by CodeRabbit

  • New Features

    • Enhanced layout for displaying hidden fields, allowing for a more flexible arrangement.
    • Added a form for users to add new hidden fields with validation for unique IDs.
    • Integrated success and error notifications for adding hidden fields.
  • Bug Fixes

    • Retained error handling for deleting hidden fields to ensure they are not removed if used in logic.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 21, 2024

Walkthrough

The changes in this pull request focus on the HiddenFieldsCard component within the survey editor. The layout for displaying hidden fields has been modified to enhance responsiveness by allowing tags to wrap. A new form has been added to enable users to add hidden fields with validation for unique IDs. Error handling for deletion remains unchanged, maintaining the component's overall control flow and state management.

Changes

File Change Summary
.../HiddenFieldsCard.tsx Updated layout for hidden fields, added a form for adding new fields with validation, retained error handling for deletions.

Assessment against linked issues

Objective Addressed Explanation
Badges should wrap for responsiveness (Issue #3882)

Possibly related PRs

Suggested labels

bug

Suggested reviewers

  • jobenjada

Poem

In the fields where hidden things lie,
We’ve made the tags dance and fly.
With forms to add, and checks in place,
Our surveys now have a better space!
So hop along, let’s celebrate,
Responsiveness now feels just great! 🐇✨


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@vercel
Copy link

vercel bot commented Oct 21, 2024

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

A member of the Team first needs to authorize it.

@github-actions
Copy link
Contributor

github-actions bot commented Oct 21, 2024

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

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Outside diff range and nitpick comments (1)
apps/web/app/(app)/(survey-editor)/environments/[environmentId]/surveys/[surveyId]/edit/components/HiddenFieldsCard.tsx (1)

Line range hint 144-190: Great addition of the form for adding new hidden fields!

The implementation of the form for adding new hidden fields is well-done and addresses the functionality improvements mentioned in the PR objectives. The validation logic ensures the uniqueness of the new hidden field ID, which is crucial for maintaining data integrity. The use of toast notifications for user feedback is a good practice.

One minor suggestion for improvement:

Consider adding a check to prevent submission of an empty hidden field ID. This can be done by disabling the submit button when the input is empty or by adding a validation check at the beginning of the form submission handler.

Example:

if (hiddenField.trim() === "") {
  toast.error("Hidden field ID cannot be empty");
  return;
}

This additional check would prevent unnecessary validation and improve user experience.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 9872d17 and cb511a3.

📒 Files selected for processing (1)
  • apps/web/app/(app)/(survey-editor)/environments/[environmentId]/surveys/[surveyId]/edit/components/HiddenFieldsCard.tsx (1 hunks)
🧰 Additional context used
🔇 Additional comments (2)
apps/web/app/(app)/(survey-editor)/environments/[environmentId]/surveys/[surveyId]/edit/components/HiddenFieldsCard.tsx (2)

128-128: Excellent fix for the responsiveness issue!

The addition of flex-wrap to the container's class is a simple yet effective solution to the responsiveness problem mentioned in the PR objectives. This change allows the hidden field tags to wrap to the next line when there's insufficient horizontal space, preventing the UI from breaking when multiple fields are added.


Line range hint 1-190: Overall assessment: Excellent implementation addressing the PR objectives

The changes in this file effectively solve the responsiveness issue with the hidden fields card and enhance its functionality. Key points:

  1. The layout fix using flex-wrap resolves the UI breaking problem when multiple fields are added.
  2. The new form for adding hidden fields is well-implemented with proper validation and error handling.
  3. The code maintains good practices in terms of state management, user feedback, and React patterns.

These changes align perfectly with the PR objectives and significantly improve the user experience of the survey editor. Great job!

Copy link
Member

@jobenjada jobenjada left a comment

Choose a reason for hiding this comment

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

thanks!

@jobenjada jobenjada enabled auto-merge October 23, 2024 23:09
@jobenjada jobenjada added this pull request to the merge queue Oct 23, 2024
Merged via the queue into formbricks:main with commit 588768c Oct 23, 2024
@oss-gg
Copy link

oss-gg bot commented Oct 23, 2024

Awarding DivyanshuLohani: 150 points 🕹️ Well done! Check out your new contribution on oss.gg/DivyanshuLohani

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.

[BUG] survey edit form hidden fields have responsiveness issue

2 participants