Skip to content

Comments

fix(#413): use max of boundingRect and scrollHeight for email iframe …#471

Merged
MrgSub merged 4 commits intoMail-0:stagingfrom
omp28:fix/Incorrect-email-heights
Mar 18, 2025
Merged

fix(#413): use max of boundingRect and scrollHeight for email iframe …#471
MrgSub merged 4 commits intoMail-0:stagingfrom
omp28:fix/Incorrect-email-heights

Conversation

@omp28
Copy link
Contributor

@omp28 omp28 commented Mar 17, 2025

Improved Email Iframe Height Calculation

Description

This PR enhances the height calculation for mail iframes to ensure all content is visible. The change implements a more robust approach that compares both the bounding rectangle height and scroll height, using whichever is larger. This fixes issues where some email content was being cut off or not displaying properly.


Type of Change

  • 🐛 Bug fix (non-breaking change which fixes an issue)
  • ⚡ Performance improvement

Areas Affected

  • Email Integration (Gmail, IMAP, etc.)
  • User Interface/Experience

Testing Done

  • Manual testing performed
  • Cross-browser testing (if UI changes)

Security Considerations

  • No sensitive data is exposed

Checklist

  • I have performed a self-review of my code
  • My code follows the project's style guidelines
  • My changes generate no new warnings

Screenshots/Recordings

423622212-9186b9de-c3bf-49cd-8b12-8b91e02032a7


By submitting this pull request, I confirm that my contribution is made under the terms of the project's license.

Summary by CodeRabbit

  • Bug Fixes
    • Enhanced the email viewing experience by improving how embedded content adjusts its height. This update ensures that all email content is fully visible, even when some elements load with a delay, preventing any clipping of the content.

@vercel
Copy link

vercel bot commented Mar 17, 2025

@omp28 is attempting to deploy a commit to the Zero Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 17, 2025

Walkthrough

The changes introduce a new function, calculateAndSetHeight, in the MailIframe component to compute the iframe's height based on both the bounding rectangle height and the scroll height. The useEffect hook now calls this function directly and includes a setTimeout to invoke it after a 500ms delay. This update replaces the previous direct height setting approach, ensuring that the iframe height is adjusted to display all content properly.

Changes

File Change Summary
apps/mail/components/mail/mail-iframe.tsx - Added calculateAndSetHeight to compute the iframe's height based on both bounding rectangle and scroll height.
- Replaced the old direct height setting in the useEffect hook with this new function.
- Included a setTimeout call to re-calculate height after 500ms.

Sequence Diagram(s)

sequenceDiagram
    participant M as MailIframe Component
    participant C as calculateAndSetHeight Function
    participant B as Iframe Body

    M->>C: Invoke calculateAndSetHeight (on mount)
    C->>B: Check for iframe body presence
    B-->>C: Return bounding rectangle height & scroll height
    C->>C: Calculate max(height, scrollHeight)
    C->>M: Set iframe height accordingly
    Note over M: Wait for 500ms delay
    M->>C: Invoke calculateAndSetHeight (after delay)
    C->>B: Re-check body dimensions
    B-->>C: Return updated dimensions
    C->>C: Recalculate max value
    C->>M: Update iframe height
Loading

Suggested reviewers

  • MrgSub

Poem

Oh, hoppy code, so nimble and light,
I scurry through updates by day and night.
New functions bloom like a garden in sight,
With setTimeout delays keeping details just right.
I nibble on bugs, then hop away with delight.
🐰💻
Happy coding from a bunny in flight!


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ec6725c and c5c5b78.

📒 Files selected for processing (1)
  • apps/mail/components/mail/mail-iframe.tsx (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/mail/components/mail/mail-iframe.tsx

🪧 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 generate docstrings to generate docstrings for this 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.

@MrgSub
Copy link
Collaborator

MrgSub commented Mar 18, 2025

Conflicts please

@omp28
Copy link
Contributor Author

omp28 commented Mar 18, 2025

@MrgSub made the changes with (callback and conflicts)

@vercel
Copy link

vercel bot commented Mar 18, 2025

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

Name Status Preview Comments Updated (UTC)
0 ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 18, 2025 8:34pm

Copy link
Collaborator

@MrgSub MrgSub left a comment

Choose a reason for hiding this comment

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

LGTM

@MrgSub MrgSub merged commit c65aeed into Mail-0:staging Mar 18, 2025
3 of 4 checks passed
@coderabbitai coderabbitai bot mentioned this pull request Jun 20, 2025
34 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants