Skip to content

fix(email-viewer): render attachments as readonly chips#4064

Open
Kiarokh wants to merge 2 commits intomainfrom
fix/email-viewer-attachment-overflow
Open

fix(email-viewer): render attachments as readonly chips#4064
Kiarokh wants to merge 2 commits intomainfrom
fix/email-viewer-attachment-overflow

Conversation

@Kiarokh
Copy link
Copy Markdown
Contributor

@Kiarokh Kiarokh commented May 7, 2026

Summary

  • Long attachment filenames and verbose mime-type strings were overflowing their card in limel-email-viewer.
  • Each attachment is now a readonly limel-chip carrying a file-type icon (reusing the same extension→icon map that limel-file uses, no duplication), the filename as the chip text (single-line ellipsis on overflow), and the file size as the chip's badge. The full filename + mime type live in the host's title attribute for hover.
  • List container uses role="list" + role="listitem" on each chip since custom elements can't be direct <ul> children.
  • Drive-by: docs(file-viewer) swap of the image URL in the basic example to a Picsum URL with an explicit .jpg.

fix: #4063

Test plan

  • Open a .eml with multiple attachments and verify the chip list renders with type icons and size badges.
  • Verify long filenames truncate with ellipsis and that hovering a chip shows the full filename + mime in the native tooltip.
  • Verify chips wrap onto multiple rows and don't overflow the surrounding card.
  • Sanity-check screen-reader announces "list of N items" and each chip as a list item.
  • Verify the basic file-viewer example renders the new image preview correctly.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes

    • Corrected a border color typo in the attachments footer.
  • New Features

    • Attachments now display file-type icons, formatted sizes, and tooltips with filename and MIME info.
  • Style

    • Reworked attachment list to a responsive flex layout with improved spacing and chip styling; improved list semantics for accessibility.
    • Updated example image and alt text in the file viewer.

Switches the image attachment in the basic file-viewer example from
a Wikimedia Commons URL to a Picsum Photos URL with an explicit `.jpg`
extension. The previous URL had no recognizable extension on its path,
which prevented the file-viewer from detecting it as an image and showed
the "cannot display preview" error in some setups.
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 7, 2026

Review Change Stack
No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: ff078362-e63f-4ccf-b2d5-67521eee7a2b

📥 Commits

Reviewing files that changed from the base of the PR and between b8e0602 and 8bf4091.

📒 Files selected for processing (2)
  • src/components/email-viewer/email-viewer.scss
  • src/components/email-viewer/email-viewer.tsx

📝 Walkthrough

Walkthrough

Email viewer attachments moved from a semantic ul/li list to a flexbox .attachment-list and rendered as readonly limel-chip elements with extension-based icons and a mime-type tooltip; SCSS refactored and typo fixed. FileViewer example image URL and alt text updated.

Changes

Attachment Display Refactor

Layer / File(s) Summary
SCSS Styling Refactor
src/components/email-viewer/email-viewer.scss
Fixed rga() typo to rgba() in attachments border; removed ul/li grid styling, added .attachment-list flexbox wrapper, and set limel-chip sizing variables.
Icon Rendering Dependencies
src/components/email-viewer/email-viewer.tsx
Added imports for getIconForFile, getIconFillColorForFile, and getIconBackgroundColorForFile.
Attachment Container
src/components/email-viewer/email-viewer.tsx
Replaced <ul> with <div class="attachment-list" role="list"> and mapped attachments through the renderer.
Attachment Item Rendering
src/components/email-viewer/email-viewer.tsx
Render attachments as readonly limel-chip (role="listitem"); derive extension for icon lookup, include mimeType in tooltip, format size into chip badge, and set icon/color/background via helpers.
Helper Removal
src/components/email-viewer/email-viewer.tsx
Removed renderSizeBadge helper used for per-item size badges.
Example Update
src/components/file-viewer/examples/file-viewer-basic.tsx
Updated example image URL and alt text to new Picsum Photos scenic landscape.

Sequence Diagram(s)

sequenceDiagram
  participant Client as EmailViewer
  participant Parser as Filename Parser
  participant Icon as Icon Helper
  participant Chip as limel-chip
  Client->>Parser: extract filename, extension, format size
  Client->>Icon: getIconForFile(extension)
  Client->>Icon: getIconFillColorForFile(extension)
  Client->>Icon: getIconBackgroundColorForFile(extension)
  Client->>Chip: render chip with icon, badge, tooltip (role=listitem)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested labels

released

Suggested reviewers

  • jgroth
  • adrianschmidt
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: refactoring attachment rendering from custom cards to readonly limel-chip elements.
Linked Issues check ✅ Passed The pull request successfully implements all coding requirements from issue #4063: prevents filename overflow with chip ellipsis, preserves full filename/mime in title attribute for accessibility, reuses extension→icon mapping, and uses list/listitem roles for screen readers.
Out of Scope Changes check ✅ Passed The file-viewer image URL update is a minor documentation change acknowledged in the PR objectives as a drive-by change, not out of scope.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/email-viewer-attachment-overflow

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


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.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 7, 2026

Documentation has been published to https://lundalogik.github.io/lime-elements/versions/PR-4064/

Copy link
Copy Markdown
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: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/components/email-viewer/email-viewer.tsx`:
- Line 234: Replace the current unreliable extension extraction (const extension
= filename.split('.').pop() ?? '') with logic that finds the last dot index and
only treats a suffix as an extension if that dot is not the first character
(i.e., dotIndex > 0); set extension to the substring after the last dot for
names like "archive.tar.gz" -> "gz", and to an empty string for names without a
dot or with a leading dot (e.g., ".gitignore"). Update the code where the local
variable extension is computed in email-viewer.tsx so downstream calls like
getIconForFile(...) and the color helper utilities receive a correct '' for
extensionless files instead of the whole filename.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: b3b8ee50-a48c-4e53-a467-3af9720b70cd

📥 Commits

Reviewing files that changed from the base of the PR and between c3e14c2 and 2cb2517.

📒 Files selected for processing (3)
  • src/components/email-viewer/email-viewer.scss
  • src/components/email-viewer/email-viewer.tsx
  • src/components/file-viewer/examples/file-viewer-basic.tsx

Comment thread src/components/email-viewer/email-viewer.tsx Outdated
@Kiarokh Kiarokh force-pushed the fix/email-viewer-attachment-overflow branch 2 times, most recently from d3d9ad3 to b8e0602 Compare May 7, 2026 11:35
Copy link
Copy Markdown
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: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/components/email-viewer/email-viewer.tsx`:
- Around line 219-226: The attachments container (the div with class
"attachment-list" and role="list") isn't associated with the visible
"Attachments" span, so screen readers announce it only as "list"; add an
accessible relationship by giving the span a unique id (e.g., attachmentsLabel)
and reference that id from the list container via aria-labelledby (or
alternatively set an aria-label) so the list reads as "Attachments"—update the
JSX around the span and the div where attachments.map and renderAttachment are
used to include this id/aria-labelledby pairing.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 96264626-3eae-430e-bff4-64355246f588

📥 Commits

Reviewing files that changed from the base of the PR and between 2cb2517 and b8e0602.

📒 Files selected for processing (2)
  • src/components/email-viewer/email-viewer.scss
  • src/components/email-viewer/email-viewer.tsx

Comment on lines 219 to 226
<span>{label}</span>
<ul>
<div class="attachment-list" role="list">
{attachments.map((attachment, index) =>
this.renderAttachment(attachment, index)
)}
</ul>
</div>
</div>
);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Accessibility: associate the "Attachments" label with the role="list" container.

Without aria-labelledby, screen readers announce the container as just "list" and drop the "Attachments" context entirely. Linking the span to the list fixes this with minimal code.

♿ Proposed fix
-            <div class="attachments">
-                <span>{label}</span>
-                <div class="attachment-list" role="list">
+            <div class="attachments">
+                <span id="attachments-label">{label}</span>
+                <div class="attachment-list" role="list" aria-labelledby="attachments-label">
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/components/email-viewer/email-viewer.tsx` around lines 219 - 226, The
attachments container (the div with class "attachment-list" and role="list")
isn't associated with the visible "Attachments" span, so screen readers announce
it only as "list"; add an accessible relationship by giving the span a unique id
(e.g., attachmentsLabel) and reference that id from the list container via
aria-labelledby (or alternatively set an aria-label) so the list reads as
"Attachments"—update the JSX around the span and the div where attachments.map
and renderAttachment are used to include this id/aria-labelledby pairing.

Long filenames and verbose mime-type strings in the attachment list
could overflow their card and bleed outside of the surrounding layout.

Replaces the bespoke attachment cards with readonly limel-chip elements,
each carrying:

- a file-type icon (reusing the extension-to-icon map already used by
  limel-file, no duplication)
- the filename as the chip text (single-line ellipsized via the chip's
  built-in truncation)
- the file size as the chip's badge
- the full filename and mime type in the host title attribute, so users
  can still see the verbose details on hover

The list container is a plain div with role=list, and each chip carries
role=listitem, since custom elements cannot be direct children of a ul.
@Kiarokh Kiarokh force-pushed the fix/email-viewer-attachment-overflow branch from b8e0602 to 8bf4091 Compare May 7, 2026 16:01
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.

file viewer: Email attachment names don't display well

1 participant