Skip to content

Commit

Permalink
[visual-editor] Null out the editor earlier (#2397)
Browse files Browse the repository at this point in the history
I noticed we were using a stale editor instance on occasion, which meant
we'd get errors about non-existent nodes. This PR nulls out the editor
instance as soon as we start a board.
  • Loading branch information
paullewis authored Jul 3, 2024
1 parent ffbf163 commit 05f3acb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
5 changes: 5 additions & 0 deletions .changeset/stupid-clocks-sleep.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@google-labs/visual-editor": patch
---

Null out the editor property sooner
9 changes: 3 additions & 6 deletions packages/visual-editor/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -849,10 +849,11 @@ export class Main extends LitElement {
this.graph = null;
this.subGraphId = null;

// TODO: Figure out how to avoid needing to null this out.
this.#editor = null;

if (startEvent.descriptor) {
this.graph = startEvent.descriptor;
// TODO: Figure out how to avoid needing to null this out.
this.#editor = null;
}
this.status = BreadboardUI.Types.STATUS.STOPPED;
this.#runObserver = null;
Expand Down Expand Up @@ -896,13 +897,9 @@ export class Main extends LitElement {
this.graph = graph;
this.#setPageTitle();
await this.#trackRecentBoard();
// TODO: Figure out how to avoid needing to null this out.
this.#editor = null;
} catch (err) {
this.url = null;
this.graph = null;
// TODO: Figure out how to avoid needing to null this out.

this.#editor = null;
this.#failedGraphLoad = true;
}
Expand Down

0 comments on commit 05f3acb

Please sign in to comment.