Case ce-0580 · Scenario scenario-ime-ui-experience

iOS Safari: Scroll anchoring failure when focusing long editors

OS: iOS 18.0 Device: iPhone / iPad Any Browser: Safari 18.x Keyboard: Virtual Keyboard Status: confirmed
ios safari-18 scrolling focus ux-jump

Phenomenon

A persistent regression in iOS 18 (Safari) affects scroll anchoring within contenteditable. Traditionally, when an element is focused, the browser is supposed to ensure the caret is visible. In recent versions, if the editor is inside a scrollable container (or the document itself is long), focusing the editor or running a command like bold causes the entire viewport to snap-jump to the top of the editor. This forces the user to manually scroll back down to find their cursor.

Reproduction Steps

  1. Create a webpage with enough content to cause vertical scrolling.
  2. Place a contenteditable div at the bottom of the page.
  3. Scroll to the bottom and click inside the editor.
  4. Try to run document.execCommand('italic') via a toolbar button.
  5. Observe the viewport position after the command executes.

Observed Behavior

  • The ‘Jump’: The scroll position of the window or the parent div resets to the top edge of the editor container.
  • Scroll Inertia Break: If the user was scrolling while focus was triggered, the inertia is canceled, and the snap happens instantly.

Impact

  • Disorienting UX: Users lose their context and must fight the browser to stay on the active line.
  • Form Submission Issues: If the ‘Save’ button is at the bottom, and the viewport jumps, the user may accidentally click a header link instead.

Browser Comparison

  • iOS Safari 18: High frequency of anchoring failure.
  • Android Chrome: Generally keeps the caret in view, though it may trigger a layout “Resize” which affects fixed elements.

References & Solutions

Mitigation: Visual Viewport Manual Sync

Use the Visual Viewport API to detect focuses and manually trigger a scrollIntoView({ behavior: 'smooth', block: 'center' }) on a temporary span placed at the selection range.

1. Long Document
... scrolling ... |
Initialize an editor with a large body of text that exceeds the screen height.
2. Trigger Focus/Command
Programmatically focus the editor or run a formatting command that updates the selection.
vs
✅ Expected
Expected: The browser should use smooth scroll anchoring to keep the active selection visible and centered in the viewport.

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: iOS 18.0
Device: iPhone / iPad Any
Browser: Safari 18.x
Keyboard: Virtual Keyboard
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.