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
- Create a contenteditable div.
- Type some text manually.
- Use JavaScript to modify the content:
element.innerHTML = 'New content'. - Try to undo (Cmd+Z).
- 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.