Phenomenon
When the contenteditable element loses and regains focus, the undo stack may be cleared unexpectedly. Users cannot undo operations that were performed before the focus change.
Reproduction example
- Make several edits in contenteditable
- Click outside to blur the element
- Click back to focus the element
- Press Ctrl+Z to undo
Observed behavior
- Undo stack is cleared
- Previous operations cannot be undone
- Undo history is lost
- User loses ability to undo
Expected behavior
- Undo stack should be preserved across focus changes
- Or behavior should be predictable
- Users should be able to undo previous operations
- History should be maintained
Browser Comparison
- Chrome/Edge: Stack may be cleared (this case)
- Firefox: Similar stack clearing behavior
- Safari: Stack clearing most unpredictable
Notes and possible direction for workarounds
- Implement custom undo/redo that persists across focus
- Save undo stack in memory
- Restore stack when element regains focus
- Document undo stack behavior for users