Case ce-0114-caret-scroll-out-of-view · Scenario scenario-caret-out-of-viewport

Caret moves outside viewport during paste operations

OS: Windows 11 Device: Desktop or Laptop Any Browser: Chrome 120.0 Keyboard: US Status: draft
caret cursor viewport paste chrome

Phenomenon

When pasting large content into a contenteditable element, the caret (cursor) may end up outside the visible viewport. Users cannot see where they are typing and must manually scroll to find the cursor.

Reproduction example

  1. Create a contenteditable element with some content
  2. Scroll to a position where cursor is visible
  3. Paste large content
  4. Check cursor position

Observed behavior

  • Cursor ends up outside visible viewport
  • User cannot see typing position
  • Must manually scroll to find cursor
  • Poor user experience

Expected behavior

  • Cursor should remain visible after paste
  • Viewport should scroll to show cursor
  • User should always see where they are typing
  • Behavior should be automatic

Browser Comparison

  • Chrome/Edge: Caret may go out of view (this case)
  • Firefox: More likely to lose caret position
  • Safari: Caret position most unpredictable

Notes and possible direction for workarounds

  • Scroll caret into view after paste
  • Use scrollIntoView() on selection
  • Check if caret is in viewport
  • Automatically scroll if needed
  • Use requestAnimationFrame for smooth scrolling
Before Paste
Hello World
Basic text, cursor at visible position
After Paste (Bug)
Hello World
[Large content...]
|
After paste, cursor moves outside viewport (| = cursor)
vs
✅ Expected
Hello World
[Large content...]
|
Expected: Cursor maintained inside viewport or auto-scroll

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: Windows 11
Device: Desktop or Laptop Any
Browser: Chrome 120.0
Keyboard: US
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.