Skip to content

[Bug]: Line breaks not displaying correctly in email TEXT content #13

@faizananwerali

Description

@faizananwerali

What happened?

Issue

The TextEntry component used to display email TEXT content does not properly render line breaks in the content.

Current behavior

Line breaks in the email TEXT content are not displayed in the UI, causing all text to appear in a single line.

Expected behavior

Line breaks should be preserved and displayed correctly in the UI.

How to reproduce the bug

  1. Create an email with multiple lines of text in the TEXT part (not HTML)
    Hello,
    
    This is a test email.
    
    Best regards,
    John
    
  2. Send this email to a mailbox monitored by filament-mails
  3. View the email in the filament-mails interface
  4. Observe that all text appears in a single line

Package Version

2.0.0

PHP Version

8.2

Laravel Version

11.x

Which operating systems does with happen with?

macOS

Notes

Solution

Modifying the TextEntry component to use HtmlString resolves the issue:

// Before (current implementation)
TextEntry::make('text')
    ->hiddenLabel()
    ->copyable()
    ->copyMessage('Copied!')
    ->copyMessageDuration(1500)
    ->label(__('Text Content'))
    ->columnSpanFull(),

// After (proposed fix)
TextEntry::make('text')
    ->hiddenLabel()
    ->copyable()
    ->copyMessage('Copied!')
    ->copyMessageDuration(1500)
    ->label(__('Text Content'))
    ->formatStateUsing(fn (string $state): HtmlString => new HtmlString(nl2br(e($state))))
    ->columnSpanFull(),

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions