Case ce-0572 · Scenario scenario-paste-plain-text

plaintext-only paste leaves trailing  

OS: Linux Ubuntu 22.04 Device: Desktop Any Browser: Chrome 121.0 Keyboard: US QWERTY Status: confirmed
plaintext-only paste nbsp layout chrome-121

Phenomenon

The contenteditable="plaintext-only" attribute was designed to eliminate the need for manual paste event interception. However, in early 2024 (Chromium 121), it was discovered that the engine incorrectly converts or preserves leading/trailing spaces as   (U+00A0) instead of standard spaces (U+0020). Since   prevents automatic line wrapping in CSS, pasted text often “breaks” the UI layout by overflowing its container.

Reproduction Steps

  1. Create a <div> with contenteditable="plaintext-only" and a fixed width (e.g., 200px).
  2. Copy a long sentence from a source that contains multiple spaces or is formatted.
  3. Paste the text into the div using the browser’s default behavior.
  4. Inspect the resulting DOM string or observe the wrapping behavior.

Observed Behavior

  1. DOM Structure: The pasted text is indeed plain text (no tags), but character examination reveals &nbsp; entities.
  2. Layout: The text remains on a single line, causing horizontal overflow or breaking the parent layout.
  3. Selection: Triple-clicking to select the line often includes the invisible &nbsp; characters, making further processing (like URL detection) fail.

Expected Behavior

All whitespace character sequences should be normalized to a single or multiple standard breaking spaces (U+0020), respecting the CSS white-space property of the container.

Impact

  • Broken UI Layout: Sidebars, chat bubbles, and comments overflow unexpectedly.
  • Search Failures: Internal search logic for the application may not match &nbsp; when searching for standard spaces.
  • Copy-Paste Loops: If the user copies the text again and pastes it elsewhere, the &nbsp; “infection” spreads to other applications.

Browser Comparison

  • Chrome / Edge (v121-122): Confirmed regression in plaintext-only mode.
  • Safari: Handles plaintext-only conversion by normalizing to standard spaces.
  • Firefox: Correct normalization during plain text extraction.

References & Solutions

Mitigation: Manual Normalization

Even with plaintext-only, you may need a short-lived listener to clean up the browser’s output if you support affected Chromium versions.

element.addEventListener('input', (e) => {
    if (element.innerHTML.includes('&nbsp;')) {
        // Warning: This can disrupt caret position if not handled carefully
        element.innerHTML = element.innerHTML.replace(/&nbsp;/g, ' ');
    }
});
Step 1: Setup Editor
|
Initialize an editor with native plaintext-only mode.
Step 2: Paste Content
long text message|
User pastes 'long text message' which contains leading/trailing spaces.
vs
✅ Expected
long text message|
Expected: All spaces should be normalized to standard breaking space (U+0020).

Browser compatibility matrix

This matrix shows which browser and OS combinations have documented cases for this scenario. The current case is highlighted. Click on a cell to view other cases.

Browser Linux macOS
Chrome
Safari
Current case
Confirmed
Draft
No case documented

All variants (detailed table)

Complete list of all cases for this scenario with full environment details.

Case OS Device Browser Keyboard Status
ce-0019-paste-plain-text-only macOS Ubuntu 22.04 Desktop or Laptop Any Safari 120.0 US draft
ce-0572 Linux Ubuntu 22.04 Desktop Any Chrome 121.0 US QWERTY confirmed

Playground for this case

Use the reported environment as a reference and record what happens in your environment while interacting with the editable area.

Reported environment
OS: Linux Ubuntu 22.04
Device: Desktop Any
Browser: Chrome 121.0
Keyboard: US QWERTY
Your environment
Sample HTML:
Event log
Use this log together with the case description when filing or updating an issue.
0 events
Interact with the editable area to see events here.

Comments & Discussion

Have questions, suggestions, or want to share your experience? Join the discussion below.