Scenario

Auto-scroll while typing in contenteditable

Browsers try to keep the caret visible by scrolling the editable container or the page. During rapid typing—especially near the bottom or right edge—scroll updates can lag, batch, or feel jarring, so the caret temporarily leaves the viewport or the view jumps unexpectedly.

performance
Scenario ID
scenario-auto-scroll-on-typing

Details

Browsers try to keep the caret visible by scrolling the editable container or the page. During rapid typing—especially near the bottom or right edge—scroll updates can lag, batch, or feel jarring, so the caret temporarily leaves the viewport or the view jumps unexpectedly.

Problem Overview

Rich editors often rely on the browser’s built-in “scroll into view” behavior for the active selection. That behavior is not specified in fine detail for contenteditable, and timing differs by engine. Editors that measure layout or virtualize lines may fight the same scroll logic, amplifying jank.

Observed Behavior

  • Lag: Scroll catches up after several keystrokes; the caret is briefly off-screen.
  • Jarring jumps: Large scroll corrections after a burst of input.
  • Performance: Noticeable cost when the editable is inside nested scrollers or heavy layouts.

Impact

Users lose track of the insertion point; accessibility users may hear updates out of sync with what is visible. Editor frameworks that assume “caret is always visible” can desynchronize internal state from DOM selection.

Browser Comparison

Blink often scrolls the nearest scrollable ancestor; WebKit may differ when the caret is near replaced elements or soft wraps. Gecko has its own scroll anchoring and undo interactions that can interact with typing near edges.

Solutions

  • Reduce work per keystroke (debounce decoration, avoid synchronous layout reads).
  • For custom scroll containers, call scrollIntoView / scrollTo on the active range with block: 'nearest' after your own layout pass—coordinate with requestAnimationFrame.
  • Consider overflow-anchor / scroll anchoring awareness when content height changes above the caret.

Best Practices

  • Do not read getBoundingClientRect on every input in hot paths.
  • Test rapid typing at the bottom of a tall contenteditable inside a max-height container.
  • ce-0122 — jarring scroll during typing
  • ce-0131 — lag when typing near edges
  • ce-0161 — scroll performance cost

References

Scenario flow

Visual view of how this scenario connects to its concrete cases and environments. Nodes can be dragged and clicked.

React Flow mini map

Variants

Each row is a concrete case for this scenario, with a dedicated document and playground.

Case OS Device Browser Keyboard Status
ce-0122-auto-scroll-jarring Windows 11 Desktop or Laptop Any Firefox 120.0 US draft
ce-0131-auto-scroll-lag-rapid-typing Windows 11 Desktop or Laptop Any Chrome 120.0 US draft
ce-0161-auto-scroll-performance Windows 11 Desktop or Laptop Any Chrome 120.0 US draft

Browser compatibility

This matrix shows which browser and OS combinations have documented cases for this scenario. Click on a cell to view the specific case.

Confirmed
Draft
No case documented

Cases

Open a case to see the detailed description and its dedicated playground.

Related Scenarios

Other scenarios that share similar tags or category.

Tags: chrome

CSS will-change may improve or degrade contenteditable performance

When a contenteditable element has CSS will-change property set, performance may be affected. In some cases, it may improve performance by hinting the browser about upcoming changes. In other cases, it may degrade performance by creating unnecessary layers.

1 case
Tags: safari

MutationObserver may interfere with contenteditable editing

When a MutationObserver is attached to a contenteditable element or its parent, the observer callbacks may interfere with editing performance. Frequent DOM mutations during typing can trigger many observer callbacks, causing lag or jank.

1 case

Comments & Discussion

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