@@ -124,7 +124,10 @@ export class StructureFocusManager extends StatefulPluginComponent<StructureFocu
}
setSnapshot(snapshot: StructureFocusSnapshot) {
- if (!snapshot.current) return;
+ if (!snapshot.current) {
+ this.clear();
+ return;
+ }
const { label, ref, bundle, category } = snapshot.current;
const structure = this.plugin.state.data.select(StateSelection.Generators.byRef(ref))[0]?.obj?.data as Structure;
@@ -260,7 +260,7 @@ export class StructureSelectionManager extends StatefulPluginComponent<Structure
if (!structure) return;
// oldObj is not defined for inserts (e.g. TransformStructureConformation)
- if (!oldObj || Structure.areUnitAndIndicesEqual(oldObj.data, obj.data)) {
+ if (!oldObj?.data || Structure.areUnitAndIndicesEqual(oldObj.data, obj.data)) {
this.entries.set(ref, remapSelectionEntry(this.entries.get(ref)!, structure));
// remap referenceLoci & prevHighlight if needed and possible