Skip to content

fix: Added DialogTitle and DialogDescrtiption components to the dialog.#3146

Merged
Dhruwang merged 6 commits intoformbricks:mainfrom
SaiSawant1:dialog-content-fix
Sep 18, 2024
Merged

fix: Added DialogTitle and DialogDescrtiption components to the dialog.#3146
Dhruwang merged 6 commits intoformbricks:mainfrom
SaiSawant1:dialog-content-fix

Conversation

@SaiSawant1
Copy link
Contributor

@SaiSawant1 SaiSawant1 commented Sep 14, 2024

This will fix the warnings and errors that appear when a any modal is opened.

dialog-content final fix

Dialog Description fix

minor fix

What does this PR do?

This PR will resolve all the warnings related to modal/dialog components.

Radix dialog content requires the DialogTitle to be children of the DialogContent.

Fixes #3098

before-fix.mov
after-fix.mov

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
  • [] 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 dialog components for sharing surveys, improving accessibility and semantic structure.
    • Updated survey link display to allow users to modify the survey URL freely.
  • Bug Fixes

    • Improved rendering performance in the Copy Survey Form by ensuring unique keys for list items.
  • Documentation

    • Added structured components for better clarity in dialog titles and descriptions across various components.

This will fix the warnings and errors that appear when a any modal is
opened.

dialog-content final fix

Dialog Description fix

minor fix
@vercel
Copy link

vercel bot commented Sep 14, 2024

@SaiSawant1 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 Sep 14, 2024

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

@github-actions github-actions bot added bug Something isn't working 🕹️ 50 points 🕹️ Level 1 🕹️ oss.gg Community issue via oss.gg 🙋🏻‍♂️help wanted Extra attention is needed labels Sep 14, 2024
@SaiSawant1 SaiSawant1 changed the title fix:Added DialogTitle and DialogDescrtiption components to the dialog. fix: Added DialogTitle and DialogDescrtiption components to the dialog. Sep 14, 2024
@jobenjada jobenjada requested a review from Dhruwang September 16, 2024 09:57
@jobenjada
Copy link
Member

@Dhruwang looks good to me, pls test and add to merge queue 🤓

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.

to enable merge once Dhru reviewed

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.

hey @SaiSawant1

There's also this modal with the Dialog Title error (and another error and warning):

image image

Please fix these, the rest looks good 🙏

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Sep 18, 2024

Warning

Rate limit exceeded

@Dhruwang has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 12 minutes and 40 seconds before requesting another review.

How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

Commits

Files that changed from the base of the PR and between 8f047ab and 9892d3f.

Walkthrough

The changes involve enhancements to dialog components across several files, focusing on adding DialogTitle, DialogDescription, and DialogHeader elements to improve semantic structure and accessibility. Additionally, modifications were made to how survey URLs are handled in input fields and the use of keys in list rendering to optimize performance. These updates address accessibility issues and improve the overall organization of dialog content.

Changes

File Change Summary
apps/web/app/(app)/environments/[environmentId]/surveys/[surveyId]/(analysis)/summary/components/ShareEmbedSurvey.tsx
apps/web/app/(app)/environments/[environmentId]/surveys/[surveyId]/(analysis)/summary/components/ShareSurveyResults.tsx
Added DialogTitle, DialogDescription, and DialogHeader components to enhance dialog structure and accessibility.
packages/ui/Modal/index.tsx Updated title rendering to use DialogPrimitive.DialogTitle and added DialogPrimitive.DialogDescription.
packages/ui/ShareSurveyLink/components/SurveyLinkDisplay.tsx Changed Input property from value to defaultValue for improved user input flexibility.
packages/ui/SurveysList/components/CopySurveyForm.tsx Added index as a key for FormField to enhance rendering performance.

Assessment against linked issues

Objective Addressed Explanation
DialogContent requires a DialogTitle (#[3098])
Missing Description or aria-describedby for {DialogContent} (#[3098])

🐇 In a garden bright and fair,
New dialogs spring up with care.
Titles and headers now align,
Accessibility's a joyful sign!
With every click, the surveys share,
A hop, a skip, we're all aware! 🎉


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 generate interesting stats about this repository and render them as a table.
    -- @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: 4

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between ebf35ea and fc36002.

Files selected for processing (5)
  • apps/web/app/(app)/environments/[environmentId]/surveys/[surveyId]/(analysis)/summary/components/ShareEmbedSurvey.tsx (2 hunks)
  • apps/web/app/(app)/environments/[environmentId]/surveys/[surveyId]/(analysis)/summary/components/ShareSurveyResults.tsx (3 hunks)
  • packages/ui/Modal/index.tsx (1 hunks)
  • packages/ui/ShareSurveyLink/components/SurveyLinkDisplay.tsx (1 hunks)
  • packages/ui/SurveysList/components/CopySurveyForm.tsx (1 hunks)
Additional comments not posted (4)
packages/ui/ShareSurveyLink/components/SurveyLinkDisplay.tsx (1)

12-12: Consider the implications of using defaultValue.

The change from value to defaultValue allows the user to freely edit the input, which enhances user experience. However, keep in mind that any changes made by the user will not be automatically reflected in the surveyUrl prop.

If you need to keep the surveyUrl in sync with user input, you'll need to implement additional logic to manage the state externally. Verify if this is required for your use case and make the necessary adjustments.

apps/web/app/(app)/environments/[environmentId]/surveys/[surveyId]/(analysis)/summary/components/ShareSurveyResults.tsx (1)

5-5: LGTM!

The import statement is correct and the imported components are used in the subsequent code changes.

apps/web/app/(app)/environments/[environmentId]/surveys/[surveyId]/(analysis)/summary/components/ShareEmbedSurvey.tsx (2)

58-61: LGTM!

The addition of DialogTitle and DialogDescription components improves the semantic structure and accessibility of the dialog. The title text is clear and appropriate. Hiding the description is a good approach if it's intended for future use or accessibility purposes without displaying additional information to the user.


10-10: LGTM!

The import statement for DialogTitle and DialogDescription components is correctly formatted and includes the necessary components from the @formbricks/ui/Dialog module.

Comment on lines +32 to +37
<DialogHeader>
<DialogTitle>
<CheckCircle2Icon className="h-20 w-20 text-slate-300" />
</DialogTitle>
</DialogHeader>
<DialogDescription className="hidden" />
Copy link
Contributor

Choose a reason for hiding this comment

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

Add a meaningful description to DialogDescription instead of hiding it.

The addition of DialogHeader and DialogTitle improves the semantic structure and accessibility of the dialog. Wrapping the icon within DialogTitle provides a meaningful title for the dialog.

However, hiding the DialogDescription defeats its purpose. The DialogDescription is meant to provide additional context for screen readers. Instead of hiding it, consider providing a meaningful description that enhances the accessibility of the dialog.

Comment on lines +82 to +87
<DialogHeader>
<DialogTitle>
<AlertCircleIcon className="h-20 w-20 text-slate-300" />
</DialogTitle>
</DialogHeader>
<DialogDescription className="hidden" />
Copy link
Contributor

Choose a reason for hiding this comment

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

Add a meaningful description to DialogDescription instead of hiding it.

The addition of DialogHeader and DialogTitle improves the semantic structure and accessibility of the dialog. Wrapping the icon within DialogTitle provides a meaningful title for the dialog.

However, hiding the DialogDescription defeats its purpose. The DialogDescription is meant to provide additional context for screen readers. Instead of hiding it, consider providing a meaningful description that enhances the accessibility of the dialog.

Comment on lines +74 to +77
<DialogPrimitive.DialogTitle>
{title && <p className="mb-4 text-xl font-bold text-slate-500">{title}</p>}
</DialogPrimitive.DialogTitle>
<DialogPrimitive.DialogDescription></DialogPrimitive.DialogDescription>
Copy link
Contributor

Choose a reason for hiding this comment

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

Use semantic HTML for the dialog title and description.

Please consider the following changes:

  1. Replace the <p> tag with an appropriate heading tag (e.g., <h2>, <h3>) for the dialog title. Using a <p> tag for the title is not semantically correct and can negatively impact SEO and accessibility.

  2. Either remove the empty DialogPrimitive.DialogDescription component or provide a meaningful description. An empty description component can confuse users of assistive technologies.

Apply this diff to address the issues:

-<DialogPrimitive.DialogTitle>
-  {title && <p className="mb-4 text-xl font-bold text-slate-500">{title}</p>}
-</DialogPrimitive.DialogTitle>
-<DialogPrimitive.DialogDescription></DialogPrimitive.DialogDescription>
+<DialogPrimitive.DialogTitle>
+  {title && <h2 className="mb-4 text-xl font-bold text-slate-500">{title}</h2>}
+</DialogPrimitive.DialogTitle>
+{description && (
+  <DialogPrimitive.DialogDescription>
+    {description}
+  </DialogPrimitive.DialogDescription>
+)}

Note: Replace description with the actual description content or remove the entire DialogPrimitive.DialogDescription block if no description is needed.

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
<DialogPrimitive.DialogTitle>
{title && <p className="mb-4 text-xl font-bold text-slate-500">{title}</p>}
</DialogPrimitive.DialogTitle>
<DialogPrimitive.DialogDescription></DialogPrimitive.DialogDescription>
<DialogPrimitive.DialogTitle>
{title && <h2 className="mb-4 text-xl font-bold text-slate-500">{title}</h2>}
</DialogPrimitive.DialogTitle>
{description && (
<DialogPrimitive.DialogDescription>
{description}
</DialogPrimitive.DialogDescription>
)}

Comment on lines +91 to +94
{product?.environments.map((environment, idx) => {
return (
<FormField
key={idx}
Copy link
Contributor

Choose a reason for hiding this comment

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

Use a unique and stable identifier for the key prop.

Using the index as the key prop is not recommended, as it can lead to issues if the order of items in the product?.environments array changes. Consider using a unique and stable identifier, such as environment.id, for the key prop instead.

Apply this diff to use environment.id as the key:

-{product?.environments.map((environment, idx) => {
+{product?.environments.map((environment) => {
   return (
     <FormField
-      key={idx}
+      key={environment.id}
       control={form.control}
       name={`products.${productIndex}.environments`}
       render={({ field }) => {

Committable suggestion was skipped due to low confidence.

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)/environments/[environmentId]/surveys/[surveyId]/(analysis)/summary/components/ShareSurveyResults.tsx (1)

Line range hint 24-86: Consider adding DialogTitle and DialogDescription to improve accessibility.

The transition from Dialog to Modal component aligns with the design system and may offer a better user experience. The core functionality of displaying survey results and handling publish/unpublish actions remains intact.

However, the removal of DialogContent, DialogTitle, and DialogDescription components may impact the accessibility and semantic structure of the dialog. Consider adding a meaningful DialogTitle and DialogDescription to provide context for screen readers and enhance accessibility.

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between fc36002 and 8f047ab.

Files selected for processing (1)
  • apps/web/app/(app)/environments/[environmentId]/surveys/[surveyId]/(analysis)/summary/components/ShareSurveyResults.tsx (4 hunks)
Additional comments not posted (1)
apps/web/app/(app)/environments/[environmentId]/surveys/[surveyId]/(analysis)/summary/components/ShareSurveyResults.tsx (1)

5-5: LGTM!

The import statement for the Modal component is correct and matches its usage in the code.

Copy link
Member

@Dhruwang Dhruwang left a comment

Choose a reason for hiding this comment

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

Looks good, Thanks @SaiSawant1 😊🚀🙌🏻

@vercel
Copy link

vercel bot commented Sep 18, 2024

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

2 Skipped Deployments
Name Status Preview Comments Updated (UTC)
formbricks-cloud ⬜️ Ignored (Inspect) Visit Preview Sep 18, 2024 9:35am
formbricks-docs ⬜️ Ignored (Inspect) Visit Preview Sep 18, 2024 9:35am

@Dhruwang Dhruwang enabled auto-merge September 18, 2024 09:35
@jobenjada
Copy link
Member

/award 50

@oss-gg
Copy link

oss-gg bot commented Sep 18, 2024

Awarding SaiSawant1: 50 points! Check out your new contribution on oss.gg/SaiSawant1

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 guys!

@Dhruwang Dhruwang added this pull request to the merge queue Sep 18, 2024
@coderabbitai coderabbitai bot mentioned this pull request Mar 17, 2025
12 tasks
@coderabbitai coderabbitai bot mentioned this pull request Jul 8, 2025
12 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working 🙋🏻‍♂️help wanted Extra attention is needed 🕹️ oss.gg Community issue via oss.gg 🕹️ 50 points

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] DialogContent requires a DialogTitle

3 participants