Phenomenon
The undo and redo functionality (Ctrl+Z / Ctrl+Y or Cmd+Z / Cmd+Shift+Z) behaves differently across browsers. Some browsers undo individual keystrokes, while others undo larger operations. The undo stack may also be cleared unexpectedly.
Reproduction example
- Create a contenteditable div.
- Type several words.
- Apply formatting (bold, italic).
- Type more text.
- Press Undo (Ctrl+Z or Cmd+Z) multiple times.
- Observe what gets undone at each step.
Observed behavior
- In Edge on Windows, undo may revert entire formatting operations rather than individual keystrokes.
- The undo stack may be cleared when focus moves away from the contenteditable.
- Redo behavior may not work consistently after certain operations.
Expected behavior
- Undo should revert changes in a predictable order (typically most recent first).
- The undo stack should persist while the contenteditable remains in focus.
- Redo should restore undone changes in reverse order.