Fix: Link dialog opens outside screen boundaries in checkbox question…#24461
Fix: Link dialog opens outside screen boundaries in checkbox question…#24461Hetsavani wants to merge 1 commit intocalcom:mainfrom
Conversation
|
@Hetsavani is attempting to deploy a commit to the cal Team on Vercel. A member of the Team first needs to authorize it. |
|
Hey there and thank you for opening this pull request! 👋🏼 We require pull request titles to follow the Conventional Commits specification and it looks like your proposed title needs to be adjusted. Details: |
|
|
WalkthroughUpdated the editor popup positioning logic to be viewport-aware. Instead of assigning top/left directly from element rects, the code now calculates positions using window dimensions, applies horizontal and vertical bounds with padding, and repositions the popup above the trigger if it would overflow below. The calculations ensure the popup stays within screen boundaries on smaller viewports (e.g., mobile/tablet). No exported or public API changes were made. Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
packages/ui/components/editor/plugins/ToolbarPlugin.tsx (1)
64-74: Consider extracting magic numbers as constants.The padding values (10px) are hardcoded in multiple places. Extracting them as named constants would improve maintainability and make it easier to adjust padding consistently if needed.
Add constants at the module level:
+const POPUP_VIEWPORT_PADDING = 10; + function positionEditorElement(editor: HTMLInputElement, rect: DOMRect | null) { if (rect === null) { editor.style.opacity = "0"; editor.style.top = "-1000px"; editor.style.left = "-1000px"; } else { const viewportWidth = window.innerWidth; const viewportHeight = window.innerHeight; - let top = rect.top + rect.height + window.pageYOffset + 10; + let top = rect.top + rect.height + window.pageYOffset + POPUP_VIEWPORT_PADDING; let left = rect.left + window.pageXOffset - editor.offsetWidth / 2 + rect.width / 2; // Ensure the popup doesn't go outside the viewport horizontally if (left < 0) { - left = 10; // Add some padding from the left edge + left = POPUP_VIEWPORT_PADDING; } else if (left + editor.offsetWidth > viewportWidth) { - left = viewportWidth - editor.offsetWidth - 10; // Add some padding from the right edge + left = viewportWidth - editor.offsetWidth - POPUP_VIEWPORT_PADDING; } // Ensure the popup doesn't go outside the viewport vertically if (top + editor.offsetHeight > viewportHeight + window.pageYOffset) { - top = rect.top + window.pageYOffset - editor.offsetHeight - 10; // Position above the element + top = rect.top + window.pageYOffset - editor.offsetHeight - POPUP_VIEWPORT_PADDING; } editor.style.opacity = "1"; editor.style.top = `${top}px`; editor.style.left = `${left}px`; } }
📜 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.
📒 Files selected for processing (1)
packages/ui/components/editor/plugins/ToolbarPlugin.tsx(1 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
⏰ 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: Install dependencies / Yarn install & cache
🔇 Additional comments (1)
packages/ui/components/editor/plugins/ToolbarPlugin.tsx (1)
58-79: Clamp popup top to viewport boundaryAfter repositioning above the trigger (line 73), ensure
topis at leastwindow.pageYOffset + 10to prevent negative values when the element is near the viewport top. Also review other directstyle.top/leftassignments inpackages/features/ee/support/components/IntercomContactForm.tsxandpackages/app-store/hitpay/components/HitPayDropIn.tsand add similar viewport constraints if needed.
|
Hi @Hetsavani, Thank you for taking the time to work on this issue and submit a PR. The differences are relatively minor refinements, but the most robust solution is merged. We encourage you to keep contributing to Cal.com |
Thank you so much! |
… editor
It fixes the UI issue of the toggle popup going outside the screen while using smartphone.
I have changed some stylings so that the whole popup appears on the screen.
Screencast.from.2025-10-15.00-04-42.webm
Mandatory Tasks (DO NOT REMOVE)
How should this be tested?
Follow the steps to reproduce in the issue.