editor.commands.undo() and redo() do nothing unless the editor is focused
#6.663 aberto em 16 de jul. de 2025
Métricas do repositório
- Stars
- (23.454 estrelas)
- Métricas de merge de PR
- (Mesclagem média 4d 13h) (46 fundiu PRs em 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.