Cas ce-0037 · Scénario scenario-undo-redo-behavior

Undo stack is cleared when programmatically modifying content

OS: macOS Ubuntu 22.04 Appareil: Desktop or Laptop Any Navigateur: Safari 120.0 Clavier: US Brouillon
undoprogrammaticsafari

Cette page n'a pas encore été traduite

Le contenu original en anglais est actuellement affiché. Nous apprécierions votre contribution à la traduction.

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.

Variantes de ce scénario

Cas OS Navigateur Statut
ce-0016 Windows 11 Edge 120.0 Brouillon
ce-0037 macOS Ubuntu 22.04 Safari 120.0 Brouillon

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

Use this editable area to reproduce the described case.

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.