diff --git a/assets/js/hooks/cell.js b/assets/js/hooks/cell.js index 77e3ae013..b6db065ba 100644 --- a/assets/js/hooks/cell.js +++ b/assets/js/hooks/cell.js @@ -86,10 +86,7 @@ const Cell = { }, disconnected() { - // When disconnected, this client is no longer seen by the server - // and misses all collaborative changes. On reconnection we want - // to clean up and mount a fresh hook, which we force by ensuring - // the DOM id doesn't match + // Reinitialize on reconnection this.el.removeAttribute("id"); }, diff --git a/assets/js/hooks/cell_editor.js b/assets/js/hooks/cell_editor.js index acf03bbe3..32402fafd 100644 --- a/assets/js/hooks/cell_editor.js +++ b/assets/js/hooks/cell_editor.js @@ -29,7 +29,9 @@ const CellEditor = { this.liveEditor.onMount(() => { // Remove the content placeholder - editorContainer.querySelector(`[data-el-skeleton]`).remove(); + const skeletonEl = + editorContainer.querySelector(`[data-el-skeleton]`); + skeletonEl && skeletonEl.remove(); }); this.el.dispatchEvent( @@ -42,6 +44,14 @@ const CellEditor = { ); }, + disconnected() { + // When disconnected, this client is no longer seen by the server + // and misses all collaborative changes. On reconnection we want + // to clean up and mount a fresh hook, which we force by ensuring + // the DOM id doesn't match + this.el.removeAttribute("id"); + }, + destroyed() { if (this.liveEditor) { this.el.dispatchEvent(