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