Skip to content

Commit

Permalink
Merge pull request #5745 from ueberdosis/update-editable-on-re-render
Browse files Browse the repository at this point in the history
fix(react): preserve editable option across renders
  • Loading branch information
guarmo authored Oct 21, 2024
2 parents ffb51d3 + 304eedb commit 4cb6f98
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/loud-maps-work.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@tiptap/react": patch
---

preserve editable option across re-renders #5547
5 changes: 4 additions & 1 deletion packages/react/src/useEditor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,10 @@ class EditorInstanceManager {
if (this.editor && !this.editor.isDestroyed && deps.length === 0) {
// if the editor does exist & deps are empty, we don't need to re-initialize the editor
// we can fast-path to update the editor options on the existing instance
this.editor.setOptions(this.options.current)
this.editor.setOptions({
...this.options.current,
editable: this.editor.isEditable,
})
} else {
// When the editor:
// - does not yet exist
Expand Down

0 comments on commit 4cb6f98

Please sign in to comment.