Skip to content

Comments

fix: improve mobile positioning for link dialog in form builder checkbox editor#24268

Merged
keithwillcode merged 3 commits intocalcom:mainfrom
kartik-212004:fix/mobile-link-dialog-positioning
Oct 25, 2025
Merged

fix: improve mobile positioning for link dialog in form builder checkbox editor#24268
keithwillcode merged 3 commits intocalcom:mainfrom
kartik-212004:fix/mobile-link-dialog-positioning

Conversation

@kartik-212004
Copy link
Contributor

What does this PR do?

This PR fixes a mobile positioning issue where the link attachment dialog in the checkbox input type within the "Add a question" feature opens outside screen boundaries on mobile and tablet devices. Users were unable to access or interact with the link dialog when editing checkbox question labels in event type advanced settings.

Visual Demo (For contributors especially)

Video Demo (if applicable):

Before Fix:

2025-10-04.10-32-35.mp4

*After Fix:

2025-10-04.10-42-05.mp4

Mandatory Tasks (DO NOT REMOVE)

  • I have self-reviewed the code (A decent size PR without self-review might be rejected).
  • I have updated the developer docs in /docs if this PR makes changes that would require a documentation change. If N/A, write N/A here and check the checkbox. (N/A - This is a bug fix that doesn't require documentation changes)
  • I confirm automated tests are in place that prove my fix is effective or that my feature works.

How should this be tested?

Environment Setup:

  • No special environment variables required
  • Standard Cal.com development environment

Test Steps:

  1. Desktop Testing:

    • Navigate to Event Types → Select/Create Event → Advanced Tab
    • Add a checkbox question and verify link dialog works normally
    • Ensure no regression in existing functionality
  2. Mobile/Tablet Testing (Critical):

    • Use browser dev tools to simulate mobile viewports (320px, 480px, 768px widths)
    • Or test on actual mobile/tablet devices
    • Follow same steps as desktop
    • Verify link dialog appears within screen boundaries
    • Test interaction with the dialog (typing URLs, saving links)

Expected Results:

  • Link dialog stays within viewport boundaries on all screen sizes
  • Dialog is fully accessible and interactive on mobile devices
  • Consistent minimum width of 200px across all breakpoints
  • No regression in desktop functionality
  • Smooth responsive behavior when resizing browser window

Test Data:

  • Any existing event type or create a new one
  • No special test data required

@kartik-212004 kartik-212004 requested review from a team as code owners October 4, 2025 05:17
@CLAassistant
Copy link

CLAassistant commented Oct 4, 2025

CLA assistant check
All committers have signed the CLA.

@graphite-app graphite-app bot added the community Created by Linear-GitHub Sync label Oct 4, 2025
@github-actions github-actions bot added the 🐛 bug Something isn't working label Oct 4, 2025
@vercel
Copy link

vercel bot commented Oct 4, 2025

@kartik-212004 is attempting to deploy a commit to the cal Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 4, 2025

Walkthrough

The link editor positioning was made viewport-aware in ToolbarPlugin.tsx: top/left are computed locally, horizontal position is clamped to a 10px margin, and vertical placement is adjusted to avoid bottom overflow (moving the editor above the anchor when needed and enforcing a minimum top inset). Calculations use window.innerWidth/innerHeight and editor dimensions with fallbacks. Two exhaustive-deps ESLint disables were removed and a specific catch clause was changed to a generic catch. In stylesEditor.css, .link-editor max-width is now min(300px, calc(100vw - 20px)).

Pre-merge checks and finishing touches

❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Out of Scope Changes Check ⚠️ Warning The removal of two ESLint disable comments and changing a specific catch clause to a generic catch in ToolbarPlugin.tsx do not relate to the linked issues’ objectives of fixing link dialog positioning and responsiveness. Please isolate or justify these lint and error‐handling adjustments in a separate commit or pull request so that the positioning fix remains clearly scoped to the related bug.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (3 passed)
Check name Status Explanation
Title Check ✅ Passed The pull request title succinctly describes the main change by stating that the mobile positioning for the link dialog in the form builder’s checkbox editor has been improved, directly reflecting the core fix implemented in this changeset without extraneous detail or unrelated terms.
Linked Issues Check ✅ Passed The code updates introduce viewport‐aware bounds and dynamic positioning in ToolbarPlugin.tsx and adjust CSS max-width to clamp the link dialog within screen margins, fully addressing the requirements from issues #24267 and CAL-6520 to keep the dialog within mobile and tablet viewports without regressions on desktop.
Description Check ✅ Passed The pull request description clearly explains the mobile positioning issue being resolved, references the linked issues, outlines testing steps, and aligns with the changes made to ensure the link dialog remains within screen boundaries on mobile and tablet devices.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Warning

Review ran into problems

🔥 Problems

Git: Failed to clone repository. Please run the @coderabbitai full review command to re-trigger a full review. If the issue persists, set path_filters to include or exclude specific files.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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: 2

🧹 Nitpick comments (1)
packages/ui/components/editor/plugins/ToolbarPlugin.tsx (1)

59-86: Prefer consistent spelling + typo fix.

Comment // tgis will has a typo. Please fix to // this will.

-    // tgis will calculate the initial position
+    // this will calculate the initial position
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 7cd8dbf and b026a84.

📒 Files selected for processing (3)
  • packages/features/form-builder/FormBuilder.tsx (2 hunks)
  • packages/ui/components/editor/plugins/ToolbarPlugin.tsx (2 hunks)
  • packages/ui/components/editor/stylesEditor.css (2 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
**/*.tsx

📄 CodeRabbit inference engine (.cursor/rules/review.mdc)

Always use t() for text localization in frontend code; direct text embedding should trigger a warning

Files:

  • packages/ui/components/editor/plugins/ToolbarPlugin.tsx
  • packages/features/form-builder/FormBuilder.tsx
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/review.mdc)

Flag excessive Day.js use in performance-critical code; prefer native Date or Day.js .utc() in hot paths like loops

Files:

  • packages/ui/components/editor/plugins/ToolbarPlugin.tsx
  • packages/features/form-builder/FormBuilder.tsx
**/*.{ts,tsx,js,jsx}

⚙️ CodeRabbit configuration file

Flag default exports and encourage named exports. Named exports provide better tree-shaking, easier refactoring, and clearer imports. Exempt main components like pages, layouts, and components that serve as the primary export of a module.

Files:

  • packages/ui/components/editor/plugins/ToolbarPlugin.tsx
  • packages/features/form-builder/FormBuilder.tsx
🧠 Learnings (1)
📚 Learning: 2025-08-29T22:57:30.382Z
Learnt from: bandhan-majumder
PR: calcom/cal.com#23454
File: packages/features/form-builder/FormBuilder.tsx:11-11
Timestamp: 2025-08-29T22:57:30.382Z
Learning: FormBuilder.tsx in packages/features/form-builder/ does not have "use client" directive at the top despite using client-side React hooks and event handlers, which suggests it should be a client component.

Applied to files:

  • packages/features/form-builder/FormBuilder.tsx
🧬 Code graph analysis (1)
packages/features/form-builder/FormBuilder.tsx (2)
packages/features/form-builder/fieldTypes.ts (1)
  • fieldTypesConfigMap (170-170)
packages/ui/components/dialog/Dialog.tsx (2)
  • Dialog (35-38)
  • DialogContent (56-117)
⏰ Context from checks skipped due to timeout of 180000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Codacy Static Code Analysis

@kartik-212004 kartik-212004 force-pushed the fix/mobile-link-dialog-positioning branch from b026a84 to 036f84a Compare October 4, 2025 06:43
@github-actions github-actions bot added the ui area: UI, frontend, button, form, input label Oct 4, 2025
Copy link
Member

@dhairyashiil dhairyashiil left a comment

Choose a reason for hiding this comment

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

The PR looks good. Please remove unnecessary comments. Making it draft until then

@dhairyashiil dhairyashiil marked this pull request as draft October 9, 2025 22:09
@dhairyashiil dhairyashiil marked this pull request as ready for review October 10, 2025 13:10
Copy link
Member

@dhairyashiil dhairyashiil left a comment

Choose a reason for hiding this comment

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

LGTM 👍🏼 , Thank you for your contribution.

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

🧹 Nitpick comments (1)
packages/ui/components/editor/plugins/ToolbarPlugin.tsx (1)

400-400: Acceptable error handling cleanup.

Changing from catch (e: unknown) to generic catch is fine since the error parameter is unused. The catch block still handles the specific "topLevelElement is root node" error as intended per the comment.

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 036f84a and d5e4734.

📒 Files selected for processing (1)
  • packages/ui/components/editor/plugins/ToolbarPlugin.tsx (2 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
**/*.tsx

📄 CodeRabbit inference engine (.cursor/rules/review.mdc)

Always use t() for text localization in frontend code; direct text embedding should trigger a warning

Files:

  • packages/ui/components/editor/plugins/ToolbarPlugin.tsx
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/review.mdc)

Flag excessive Day.js use in performance-critical code; prefer native Date or Day.js .utc() in hot paths like loops

Files:

  • packages/ui/components/editor/plugins/ToolbarPlugin.tsx
**/*.{ts,tsx,js,jsx}

⚙️ CodeRabbit configuration file

Flag default exports and encourage named exports. Named exports provide better tree-shaking, easier refactoring, and clearer imports. Exempt main components like pages, layouts, and components that serve as the primary export of a module.

Files:

  • packages/ui/components/editor/plugins/ToolbarPlugin.tsx
🔇 Additional comments (1)
packages/ui/components/editor/plugins/ToolbarPlugin.tsx (1)

60-83: LGTM! Comprehensive viewport-aware positioning logic.

The positioning implementation correctly addresses the mobile/tablet positioning issue with robust edge-case handling:

  • Horizontal clamping (lines 68-72) ensures the dialog stays within viewport bounds with 10px margins
  • Vertical positioning (lines 74-80) intelligently repositions above the anchor when bottom overflow is detected
  • Top clamping (lines 77-79) prevents the dialog from being pushed above the viewport when the editor is taller than the viewport, addressing the concern from the previous review

The fallback dimensions (300px width, 100px height) align well with the CSS max-width constraint mentioned in the PR.

Please verify the fix works as expected on mobile/tablet devices following the testing instructions:

  • Test at viewport widths 320px, 480px, and 768px
  • Confirm the dialog stays within viewport and maintains 200px minimum width
  • Verify no regressions on desktop

Copy link
Member

@dhairyashiil dhairyashiil left a comment

Choose a reason for hiding this comment

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

LGTM 👍🏼

@keithwillcode keithwillcode enabled auto-merge (squash) October 24, 2025 20:52
@github-actions
Copy link
Contributor

github-actions bot commented Oct 24, 2025

E2E results are ready!

@keithwillcode keithwillcode merged commit 7fd28c3 into calcom:main Oct 25, 2025
70 of 78 checks passed
KartikLabhshetwar pushed a commit to KartikLabhshetwar/cal.com that referenced this pull request Oct 25, 2025
…box editor (calcom#24268)

* Updated positionEditorElement function to respect viewport boundaries

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

Labels

🐛 bug Something isn't working community Created by Linear-GitHub Sync ready-for-e2e size/S ui area: UI, frontend, button, form, input

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: Link dialog opens outside screen boundaries in checkbox question editor

4 participants