Phenomenon
When using preventDefault() and implementing custom text insertion in Chrome, those operations cannot be undone using Ctrl+Z. The undo stack does not include custom text insertions.
Reproduction example
- Implement custom text insertion with
preventDefault() - Insert some text
- Press Ctrl+Z to undo
Observed behavior
- Text insertion is not undone
- Browser’s undo stack does not include the operation
- User cannot undo custom text insertions
- Undo/redo functionality is broken for custom features
Expected behavior
- Custom text insertion should be undoable
- Undo stack should include all operations
- Ctrl+Z should work for custom insertions
- Redo should also work
Browser Comparison
- All browsers: Custom operations not in undo stack
- This is expected when using
preventDefault() - Custom undo/redo implementation needed
Notes and possible direction for workarounds
- Implement custom undo/redo stack
- Save state before each text insertion
- Restore state on undo
- Handle Ctrl+Z and Ctrl+Y manually