Browse Source

fix: Scene lookup failing when looking up by id (#5542)

David Luzar 2 years ago
parent
commit
93cccd596a
1 changed files with 5 additions and 0 deletions
  1. 5 0
      src/scene/Scene.ts

+ 5 - 0
src/scene/Scene.ts

@@ -29,9 +29,14 @@ class Scene {
 
   static mapElementToScene(elementKey: ElementKey, scene: Scene) {
     if (isIdKey(elementKey)) {
+      // for cases where we don't have access to the element object
+      // (e.g. restore serialized appState with id references)
       this.sceneMapById.set(elementKey, scene);
     } else {
       this.sceneMapByElement.set(elementKey, scene);
+      // if mapping element objects, also cache the id string when later
+      // looking up by id alone
+      this.sceneMapById.set(elementKey.id, scene);
     }
   }