Reinitialize cell editor on reconnection (#1146)

This commit is contained in:
Jonatan Kłosko 2022-04-28 13:02:20 +02:00 committed by GitHub
parent d11084d32f
commit 25e5d874be
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 5 deletions

View file

@ -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");
},

View file

@ -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(