Case ce-0037-undo-stack-cleared · Scenario scenario-undo-redo-behavior

Undo stack is cleared when programmatically modifying content

OS: macOS Ubuntu 22.04 Device: Desktop or Laptop Any Browser: Safari 120.0 Keyboard: US Status: draft
undo programmatic safari

Phenomenon

When programmatically modifying the content of a contenteditable region (e.g., using innerHTML or textContent), the undo stack is cleared in Safari. This prevents users from undoing their previous manual edits.

Reproduction example

  1. Create a contenteditable div.
  2. Type some text manually.
  3. Use JavaScript to modify the content: element.innerHTML = 'New content'.
  4. Try to undo (Cmd+Z).
  5. Observe whether the previous manual edits can be undone.

Observed behavior

  • In Safari on macOS, programmatic content changes clear the undo stack.
  • Users cannot undo their previous manual edits after programmatic changes.
  • The undo history is lost unexpectedly.

Expected behavior

  • Programmatic changes should not clear the undo stack for manual edits.
  • Or, there should be a way to preserve undo history across programmatic modifications.
  • The undo stack should be managed more intelligently.
Before
Hello World
Manually entered text
After Programmatic Change
New content
innerHTML changed programmatically
vs
✅ Expected
Hello World
Expected: Previous manual edits can be restored with Undo

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 Windows macOS
Edge
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-0016-undo-redo-inconsistent Windows 11 Desktop or Laptop Any Edge 120.0 US draft
ce-0037-undo-stack-cleared macOS Ubuntu 22.04 Desktop or Laptop Any Safari 120.0 US draft

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: macOS Ubuntu 22.04
Device: Desktop or Laptop Any
Browser: Safari 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.