Skip to content

fix: issue of triggering opening and closing question paper on clicking on submenu options#3506

Merged
mattinannt merged 2 commits intoformbricks:mainfrom
SharadK10:fix/question-paper-submenu-trigger
Oct 12, 2024
Merged

fix: issue of triggering opening and closing question paper on clicking on submenu options#3506
mattinannt merged 2 commits intoformbricks:mainfrom
SharadK10:fix/question-paper-submenu-trigger

Conversation

@SharadK10
Copy link
Contributor

@SharadK10 SharadK10 commented Oct 12, 2024

What does this PR do?

Disabled the onClick option for the submenu options so that the question paper is not triggered when clicking on the options.

Fixes #3485

REC-20241012062552.mp4

Summary by CodeRabbit

  • New Features

    • Improved user interaction in the Editor Card Menu with enhanced dropdown functionality for "Change question type" and "Add question below".
  • Bug Fixes

    • Resolved issues with unintended dropdown behavior by adding event handlers to prevent default actions.

@vercel
Copy link

vercel bot commented Oct 12, 2024

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

A member of the Team first needs to authorize it.

@CLAassistant
Copy link

CLAassistant commented Oct 12, 2024

CLA assistant check
All committers have signed the CLA.

@github-actions github-actions bot added the bug Something isn't working label Oct 12, 2024
@github-actions
Copy link
Contributor

github-actions bot commented Oct 12, 2024

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

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 12, 2024

Walkthrough

The pull request modifies the EditorCardMenu component in the EditorCardMenu.tsx file by adding onClick event handlers to the DropdownMenuSubTrigger elements for "Change question type" and "Add question below". These handlers prevent the default action when the triggers are clicked, addressing an issue where the question editor would toggle open and closed. The core functionality of the component remains unchanged.

Changes

File Change Summary
apps/web/app/(app)/(survey-editor)/environments/[environmentId]/surveys/[surveyId]/edit/components/EditorCardMenu.tsx Added onClick event handlers to prevent default actions for dropdown triggers.

Assessment against linked issues

Objective Addressed Explanation
Clicking on sub-menu should not toggle the question editor (#3485)

Possibly related PRs

  • fix: load more button applies filter #3167: The changes in the MultipleChoiceSummary component involve enhancing event handling similar to the onClick event handlers added in the EditorCardMenu component, indicating a focus on improving user interaction within components.

Suggested reviewers

  • jobenjada

Poem

In the garden of code, we hop and play,
Fixing bugs that come our way.
With clicks so smooth, the menus glide,
No more toggles, let joy abide!
A hop, a skip, in code we trust,
For a seamless flow, it's a must! 🐇✨


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.

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/EditorCardMenu.tsx (1)

212-214: LGTM: Prevents unintended question editor toggling for "Add question below".

This change effectively addresses the issue described in #3485 for the "Add question below" submenu, similar to the previous change. It prevents the default action, stopping the propagation of the click event.

Consider extracting the onClick handler to a reusable function to improve code maintainability, as it's identical for both submenu triggers. For example:

const preventDefaultClick = (e: React.MouseEvent) => e.preventDefault();

// Then use it in both DropdownMenuSubTrigger components:
<DropdownMenuSubTrigger
  className="cursor-pointer text-sm text-slate-600 hover:text-slate-700"
  onClick={preventDefaultClick}>
  // ... content ...
</DropdownMenuSubTrigger>

This refactoring would reduce code duplication and make future updates easier.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 0145589 and e360125.

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

169-171: LGTM: Prevents unintended question editor toggling.

This change effectively addresses the issue described in #3485 by preventing the default action when clicking on the "Change question type" submenu. It stops the propagation of the click event, which should resolve the unintended opening and closing of the question editor.


Line range hint 1-280: Summary: PR successfully addresses the issue and meets objectives.

This PR effectively resolves the issue described in #3485 by preventing the default action on submenu clicks. The implementation is correct and aligned with the project's goals. The changes successfully stop the unintended opening and closing of the question editor when interacting with submenu options.

A minor suggestion for code improvement has been made to enhance maintainability. Overall, this PR is ready to be merged after addressing the refactoring suggestion if deemed necessary.

@mattinannt mattinannt changed the title Fixed the issue of triggering opening and closing question paper on clicking on submenu options fix: issue of triggering opening and closing question paper on clicking on submenu options Oct 12, 2024
Copy link
Member

@mattinannt mattinannt left a comment

Choose a reason for hiding this comment

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

@SharadK10 thank you for the fix 🎉💪

@mattinannt mattinannt enabled auto-merge October 12, 2024 05:57
@mattinannt mattinannt added 🕹️ oss.gg Community issue via oss.gg 🕹️ 150 points labels Oct 12, 2024
@mattinannt mattinannt added this pull request to the merge queue Oct 12, 2024
Merged via the queue into formbricks:main with commit 6fa805e Oct 12, 2024
@oss-gg
Copy link

oss-gg bot commented Oct 12, 2024

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

@SharadK10
Copy link
Contributor Author

@SharadK10 thank you for the fix 🎉💪

Thanks @mattinannt for reviewing and merging my request looking forward make many more contributions to the community.😊

SaiSawant1 pushed a commit to SaiSawant1/formbricks that referenced this pull request Oct 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working 🕹️ oss.gg Community issue via oss.gg 🕹️ 150 points

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Clicking on Sub Menu of Question's Editor Triggers Opening and Closing of the Question Editor

3 participants