editor.commands.undo() and redo() do nothing unless the editor is focused
#6,663 opened on Jul 16, 2025
Repository metrics
- Stars
- (23,454 stars)
- PR merge metrics
- (Avg merge 4d 13h) (46 merged PRs in 30d)
Description
Affected Packages
all
Version(s)
3.0
Bug Description
While building a custom toolbar using TipTap v3, I found that calling editor.commands.undo() or editor.commands.redo() doesn't trigger the expected behavior unless I call .focus() first. This is not mentioned in the docs and leads to confusing behavior when using toolbar buttons outside the editor context.
Initialize TipTap editor with StarterKit and History
Add custom buttons calling:
editor.commands.undo(); // or editor.commands.redo() Make any change (e.g., type "Hello") Click the Undo button:❌ Nothing happens
after trying:
editor.chain().focus().undo().run();
✅ Works immediately
Browser Used
Chrome
Code Example URL
No response
Expected Behavior
Undo/Redo should work regardless of whether the editor is currently focused, especially when triggered via UI buttons like a floating or fixed toolbar.
editor.commands.undo() or redo() do nothing unless editor is focused .chain().focus().undo().run() works as expected
Additional Context (Optional)
No response
Dependency Updates
- Yes, I've updated all my dependencies.