Skip to content

feat: add descriptive for question types#3356

Merged
jobenjada merged 6 commits intoformbricks:mainfrom
ChaseNelson:feat/question-type-tooltip
Oct 15, 2024
Merged

feat: add descriptive for question types#3356
jobenjada merged 6 commits intoformbricks:mainfrom
ChaseNelson:feat/question-type-tooltip

Conversation

@ChaseNelson
Copy link
Contributor

@ChaseNelson ChaseNelson commented Oct 10, 2024

What does this PR do?

Fixes #2268

Provides tooltips that provide descriptions for each question type, helping users to better understand the various question options available when creating surveys.

https://www.loom.com/share/c3806f053e7f440eb2aab0578b8130c0?sid=a2062ad5-14a2-41cb-ac73-d4ba1c2b5277

image

How should this be tested?

  1. Create or edit a survey.
  2. In the survey editor, open the "Add Question" accordion.
  3. Mouse over any of the question types to display a tooltip with the description of the question.

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

    • Introduced tooltips for the Add Question buttons, providing contextual descriptions of question types on hover.
    • Updated descriptions for various question types to enhance clarity and specificity regarding expected responses.
  • Bug Fixes

    • Enhanced user interaction by improving the visibility of question type information.

@vercel
Copy link

vercel bot commented Oct 10, 2024

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

A member of the Team first needs to authorize it.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 10, 2024

Walkthrough

The changes in this pull request introduce a tooltip feature to the AddQuestionButton component within the AddQuestionButton.tsx file. This enhancement involves importing tooltip-related components from the @formbricks/ui/components/Tooltip module and wrapping existing button elements in a TooltipProvider. Each button now displays a tooltip that provides contextual descriptions of the question types when hovered over, improving user interaction and understanding.

Changes

File Change Summary
apps/web/app/(app)/(survey-editor)/environments/[environmentId]/surveys/[surveyId]/edit/components/AddQuestionButton.tsx Added tooltip functionality by importing Tooltip, TooltipContent, TooltipProvider, and TooltipTrigger, and wrapping buttons in TooltipProvider for enhanced user interaction.
packages/lib/utils/questions.tsx Updated descriptions of various question types for clarity and specificity.

Assessment against linked issues

Objective Addressed Explanation
Add a tooltip for each question type (#[2268])

Possibly related PRs

  • fix: wrong tooltip in survey copy form #3341: The changes in this PR involve tooltips in the CopySurveyForm component, which is directly related to the tooltip functionality introduced in the AddQuestionButton component of the main PR. Both PRs modify tooltip behavior in survey-related components.

Suggested labels

🕹️ oss.gg, 🕹️ 150 points

Suggested reviewers

  • mattinannt

🐰 In the meadow, a button did gleam,
With tooltips now, it’s more than a dream!
Hover and learn, what each question can do,
A friendly guide, just for you!
So click with delight, let curiosity bloom,
In this garden of questions, there's always more room! 🌼


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.

@github-actions github-actions bot added the enhancement New feature or request label Oct 10, 2024
@github-actions
Copy link
Contributor

github-actions bot commented Oct 10, 2024

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

@ChaseNelson ChaseNelson changed the title Feat: Add descriptive for question types feat: add descriptive for question types Oct 10, 2024
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: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 75d7579 and fd68c86.

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

[error] 50-50: Missing key property for this element in iterable.

The order of the items may change, and having a key can help React identify which item was moved.
Check the React documentation.

(lint/correctness/useJsxKeyInIterable)

🔇 Additional comments (3)
apps/web/app/(app)/(survey-editor)/environments/[environmentId]/surveys/[surveyId]/edit/components/AddQuestionButton.tsx (3)

15-15: LGTM: Tooltip components imported correctly

The new import statement for Tooltip components is correctly placed and imports the necessary components used in the changes below.


50-76: LGTM: Tooltip implementation enhances user experience

The tooltip implementation successfully adds descriptive information for each question type, aligning with the PR objective. The use of TooltipProvider, Tooltip, TooltipContent, and TooltipTrigger components is correct and maintains the existing button functionality while adding the new tooltip feature.

The delayDuration prop on TooltipProvider is a good addition to prevent accidental triggering of tooltips.

🧰 Tools
🪛 Biome

[error] 50-50: Missing key property for this element in iterable.

The order of the items may change, and having a key can help React identify which item was moved.
Check the React documentation.

(lint/correctness/useJsxKeyInIterable)


Line range hint 15-76: Summary: Tooltip implementation successfully addresses PR objectives

The changes in this file effectively implement tooltips for question types, aligning well with the PR objectives and the linked issue #2268. The tooltips provide clear descriptions for each question type, which should improve user onboarding and product usability as intended.

Key points:

  1. Tooltip components are correctly imported and implemented.
  2. Each question type button now has an informative tooltip.
  3. The implementation maintains existing functionality while adding the new feature.

These changes should significantly enhance the user experience during survey creation, making it easier for users to understand and select appropriate question types.

🧰 Tools
🪛 Biome

[error] 50-50: Missing key property for this element in iterable.

The order of the items may change, and having a key can help React identify which item was moved.
Check the React documentation.

(lint/correctness/useJsxKeyInIterable)

@mattinannt mattinannt requested a review from jobenjada October 12, 2024 06:42
@jobenjada
Copy link
Member

great idea! I've updated the UI but loved the idea :)

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.

LGTM!

@jobenjada jobenjada enabled auto-merge October 15, 2024 00:19
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: 1

🧹 Outside diff range and nitpick comments (3)
packages/lib/utils/questions.tsx (3)

127-127: LGTM with a suggestion: Improved description for NPS question type.

The updated description "Measure Net-Promoter-Score (0-10)" is more accurate and aligns well with the PR objectives. It correctly uses the full term instead of the acronym and maintains important scale information.

Suggestion for further clarity:
Consider changing to "Measure Net Promoter Score (NPS) on a 0-10 scale" to include both the full term and the commonly used acronym.


181-181: LGTM with a suggestion: Improved description for Consent question type.

The updated description "Ask to agree to terms, conditions, or data usage" provides more specific examples of what users might be consenting to, enhancing clarity and user understanding.

Suggestion for further improvement:
Consider changing to "Ask users to agree to terms, conditions, or data usage" to maintain consistency with other descriptions that explicitly mention "users" or "respondents".


Line range hint 53-237: Excellent enhancements: Significantly improved question type descriptions.

The updates to all 15 question type descriptions represent a substantial improvement in clarity, specificity, and user-friendliness. These changes consistently:

  1. Provide more context and examples where appropriate.
  2. Use consistent language across descriptions (e.g., "Ask for" instead of "Allow").
  3. Focus on the purpose and functionality of each question type.
  4. Align perfectly with the PR objective of enhancing user understanding.

These improvements will greatly assist users in selecting the appropriate question types for their surveys, thereby enhancing the overall user experience and product usability.

Consider creating a separate configuration file for these descriptions to facilitate easier updates and potential internationalization in the future.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between efbeb26 and c7023e5.

📒 Files selected for processing (2)
  • apps/web/app/(app)/(survey-editor)/environments/[environmentId]/surveys/[surveyId]/edit/components/AddQuestionButton.tsx (4 hunks)
  • packages/lib/utils/questions.tsx (15 hunks)
🧰 Additional context used
🔇 Additional comments (13)
packages/lib/utils/questions.tsx (13)

53-53: LGTM: Improved description clarity for OpenText question type.

The updated description "Collect open-ended feedback" provides a clearer explanation of the question type's purpose, aligning well with the PR objective of enhancing user understanding.


65-65: LGTM: Enhanced user-friendly description for MultipleChoiceSingle.

The new description "Offer a list of options (choose one)" is more user-centric and easier to understand, especially for non-technical users. This change supports the PR's goal of improving user onboarding.


79-79: LGTM: Consistent and clear description for MultipleChoiceMulti.

The updated description "Offer a list of options (choose multiple)" maintains consistency with the MultipleChoiceSingle description style while clearly indicating the ability to select multiple options. This change enhances user understanding and supports the PR's objectives.


94-94: LGTM: Refined description for PictureSelection question type.

The updated description "Ask respondents to choose one or more images" uses more precise terminology while maintaining clarity. This minor refinement contributes to the overall goal of providing clear explanations for each question type.


114-114: Excellent improvement: Enhanced description for Rating question type.

The updated description "Ask respondents for a rating (stars, smileys, numbers)" provides valuable context by including examples of rating types. This addition effectively communicates the versatility of the rating question, significantly enhancing user understanding of its functionality.


138-138: LGTM: Enhanced clarity for Ranking question type.

The updated description "Ask respondents to order items by preference or importance" provides valuable context about the purpose of ranking. This change improves user understanding by clearly communicating the question type's functionality and potential use cases.


154-154: Excellent improvement: Significantly enhanced description for Matrix question type.

The new description "Create a grid to rate multiple items on the same set of criteria" is a substantial improvement. It clearly explains both the structure and purpose of the matrix question, greatly enhancing user understanding. This change exemplifies the PR's objective of providing clearer explanations of question functionalities.


165-165: LGTM: Comprehensive description update for CTA question type.

The new description "Display information and prompt users to take a specific action" is more comprehensive and accurate. It now includes the crucial aspect of displaying information and specifies the nature of the action. This change significantly improves user understanding of the CTA question type's functionality.


192-192: LGTM: Enhanced clarity and context for FileUpload question type.

The updated description "Enable respondents to upload documents, images, or other files" provides valuable examples and context. This change effectively communicates the versatility of the file upload functionality, significantly improving user understanding. The use of "Enable" also adds a more positive tone to the description.


202-202: LGTM: Concise and consistent description for Date question type.

The updated description "Ask for a date selection" is more concise while maintaining the essential information. This change improves consistency with other question type descriptions and supports the PR's goal of providing clear explanations.


212-212: Excellent improvement: Significantly enhanced description for Cal question type.

The new description "Ask respondents to book a time slot for meetings or calls" is a substantial improvement. It clearly specifies the action and purpose of the question type, providing valuable context for its use. This change exemplifies the PR's objective of enhancing user understanding and providing clearer explanations of question functionalities.


222-222: LGTM: Concise and specific description for Address question type.

The updated description "Ask for a mailing address" is more concise and specific. It clearly communicates the purpose of the question type while maintaining consistency with other descriptions. This change supports the PR's goal of providing clear and user-friendly explanations.


237-237: Excellent improvement: Comprehensive and specific description for ContactInfo question type.

The new description "Ask for name, surname, email, phone number and company jointly" is a significant enhancement. It provides a detailed list of the information collected, clearly communicating the scope and purpose of this question type. The use of "jointly" effectively emphasizes that all this information is gathered in a single question. This change exemplifies the PR's objective of providing clear, specific explanations that enhance user understanding.


export const AddQuestionButton = ({ addQuestion, product, isCxMode }: AddQuestionButtonProps) => {
const [open, setOpen] = useState(false);
const [hoveredQuestionId, setHoveredQuestionId] = useState<string | null>(null);
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Consider using @radix-ui/react-tooltip for accessible tooltips

Using React state (hoveredQuestionId) and hover event handlers to manage tooltip visibility can lead to unnecessary re-renders and may not provide the best accessibility support, especially for keyboard and screen reader users. @radix-ui/react-tooltip offers an accessible and flexible tooltip component that handles these concerns.

Apply the following changes to implement tooltips using @radix-ui/react-tooltip:

  1. Install the Tooltip package if it's not already installed:

    npm install @radix-ui/react-tooltip
  2. Import the Tooltip components:

    +import * as Tooltip from "@radix-ui/react-tooltip";
  3. Wrap each question type button with Tooltip components:

      {availableQuestionTypes.map((questionType) => (
    +   <Tooltip.Provider delayDuration={50}>
    +     <Tooltip.Root>
    +       <Tooltip.Trigger asChild>
          <button
            type="button"
            key={questionType.id}
            className="group relative mx-2 inline-flex items-center justify-between rounded p-0.5 px-4 py-2 text-sm font-medium text-slate-700 last:mb-2 hover:bg-slate-100 hover:text-slate-800"
            onClick={() => {
              addQuestion({
                ...universalQuestionPresets,
                ...getQuestionDefaults(questionType.id, product),
                id: createId(),
                type: questionType.id,
              });
              setOpen(false);
            }}
    -       onMouseEnter={() => setHoveredQuestionId(questionType.id)}
    -       onMouseLeave={() => setHoveredQuestionId(null)}>
    +       >
            <div className="flex items-center">
              <questionType.icon className="text-brand-dark -ml-0.5 mr-2 h-4 w-4" aria-hidden="true" />
              {questionType.label}
            </div>
    -       <div
    -         className={`absolute right-4 text-xs font-light text-slate-500 transition-opacity duration-200 ${
    -           hoveredQuestionId === questionType.id ? "opacity-100" : "opacity-0"
    -         }`}>
    -         {questionType.description}
    -       </div>
          </button>
    +       </Tooltip.Trigger>
    +       <Tooltip.Content
    +         side="right"
    +         align="center"
    +         className="bg-slate-800 text-white rounded px-2 py-1 text-xs"
    +       >
    +         {questionType.description}
    +       </Tooltip.Content>
    +     </Tooltip.Root>
    +   </Tooltip.Provider>
        ))}

This refactor enhances accessibility, reduces unnecessary state management, and simplifies the code by leveraging a well-tested tooltip library.

Also applies to: 63-64, 70-74

@jobenjada jobenjada added this pull request to the merge queue Oct 15, 2024
Merged via the queue into formbricks:main with commit 03df021 Oct 15, 2024
@oss-gg
Copy link

oss-gg bot commented Oct 15, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request 🕹️ oss.gg Community issue via oss.gg 🕹️ 300 points

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] Explain question types with tooltip

3 participants