fix: prevent external CSS from breaking Cal.com embed#22778
fix: prevent external CSS from breaking Cal.com embed#22778hariombalhara merged 25 commits intocalcom:mainfrom
Conversation
|
""" WalkthroughThe Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Assessment against linked issues
Assessment against linked issues: Out-of-scope changesNo out-of-scope changes were found. Note 🔌 MCP (Model Context Protocol) integration is now available in Early Access!Pro users can now connect to remote MCP servers under the Integrations page to get reviews and chat conversations that understand additional development context. 📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
✨ Finishing Touches
🧪 Generate unit tests
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
|
@sahitya-chandra is attempting to deploy a commit to the cal Team on Vercel. A member of the Team first needs to authorize it. |
Graphite Automations"Add consumer team as reviewer" took an action on this PR • (07/28/25)1 reviewer was added to this PR based on Keith Williams's automation. "Add community label" took an action on this PR • (07/28/25)1 label was added to this PR based on Keith Williams's automation. |
There was a problem hiding this comment.
Actionable comments posted: 1
🔭 Outside diff range comments (1)
packages/embeds/embed-core/src/embed.css (1)
4-10: Second half of the bug-fix (iframecolor-scheme) is missingIssue #22777 / CAL-6163 also describes host CSS that applies
iframe { color-scheme: normal; }, breaking our transparent iframe.
This rule is not addressed here, so the embed can still appear with an incorrect background.Add a targeted override:
+.cal-embed iframe { + /* Reset host-page rule to restore transparency */ + color-scheme: unset !important; +}Without this, the PR only fixes half of the reported breakage.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
packages/embeds/embed-core/src/embed.css(1 hunks)
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: hariombalhara
PR: calcom/cal.com#22547
File: packages/embeds/embed-core/src/lib/eventHandlers/scrollByDistanceEventHandler.ts:11-14
Timestamp: 2025-07-16T11:46:28.759Z
Learning: In Cal.com's embed system, internal events like "__scrollByDistance" are fired by Cal.com's own code, so runtime validation of event data structure is unnecessary since TypeScript type system guarantees type safety for internal events.
packages/embeds/embed-core/src/embed.css (1)
Learnt from: hariombalhara
PR: #22547
File: packages/embeds/embed-core/src/lib/eventHandlers/scrollByDistanceEventHandler.ts:11-14
Timestamp: 2025-07-16T11:46:28.759Z
Learning: In Cal.com's embed system, internal events like "__scrollByDistance" are fired by Cal.com's own code, so runtime validation of event data structure is unnecessary since TypeScript type system guarantees type safety for internal events.
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Detect changes
|
cc @hariombalhara for a quick review |
| embedStore.theme = window?.getEmbedTheme?.(); | ||
|
|
||
| // Initialize with color-scheme: unset and transparent background to prevent opaque background issues | ||
| document.documentElement.style.colorScheme = "unset"; |
There was a problem hiding this comment.
This is the cal.com app itself we don't want to force css here
There was a problem hiding this comment.
@hariombalhara sir, I have removed the forced CSS. Please have a look !!
| document.documentElement.style.colorScheme = colorScheme || "unset"; | ||
| document.body.style.background = "transparent"; |
There was a problem hiding this comment.
I meant that we shouldn't modify anything in the iframe. Inside the iframe, cal.com code is there, we already handle that correctly.
| min-height: 300px; | ||
| margin: 0 auto; | ||
| width: 100%; | ||
| display: block !important; |
There was a problem hiding this comment.
Can we confirm that the element that .cal-embed class always has display: block(and not flex or hidden or something else) ?
This is important because if there is some condition where that element's display becomes flex or hidden temporarily, it would stop working.
There was a problem hiding this comment.
Also, were you able to test it out. Please add a loom demonstrating that a webpage even after having these css props set for .cal-embed, the embed is still not affected.
|
@hariombalhara sir, I created a simple React app to test the embed, and then I added this external CSS in after adding this I test both main branchScreencast.from.2025-09-01.00-27-01.webmcal-6163 branch(current branch)Screencast.from.2025-09-01.00-30-09.webm |
|
Embed is not breaking after adding these new css but adding external css can still override the embed (but it did not break the embed) |
|
@hariombalhara sir I have added the video proof, can you have a look |
|
thanks, I will check soon!! |
|
Thanks @sahitya-chandra !! Approved |
|
@hariombalhara sir this didn't get auto-merged yet!! |
|
Getting it merged @sahitya-chandra !! Sorry |
E2E results are ready! |
|
@hariombalhara thanks a lot sir, for guiding me throughout this PR... |
* fix: added block display to .cal-embed * fixed the iframe color-scheme to unset and bg transparent * removed forced CSS * changes reverted from iframe * Add comments and remove background transparent as it is still not needed --------- Co-authored-by: Anik Dhabal Babu <81948346+anikdhabal@users.noreply.github.com> Co-authored-by: Hariom Balhara <hariombalhara@gmail.com>
What does this PR do?
Visual Demo (For contributors especially)
A visual demonstration is strongly recommended, for both the original and new change (video / image - any one).
Video Demo (if applicable):
Image Demo (if applicable):
Mandatory Tasks (DO NOT REMOVE)
How should this be tested?
Checklist