diff --git a/src/apps/rednatco/index.tsx b/src/apps/rednatco/index.tsx index 560639472edd520d7521e47ad5da2693e98a7d44..ae047f25ba34a73aaf53a2cf483549bc7d65e228 100644 --- a/src/apps/rednatco/index.tsx +++ b/src/apps/rednatco/index.tsx @@ -155,9 +155,7 @@ export class ReDNATCOMsp extends React.Component<ReDNATCOMsp.Props, State> { } else if (type === 'current-model-number') { return Api.Queries.CurrentModelNumber(this.viewer!.currentModelNumber()); } else if (type === 'selected-step') { - if (this.selectedStep) - return Api.Queries.SelectedStep(this.selectedStep); - return Api.Queries.SelectedStep(); + return this.selectedStep ? Api.Queries.SelectedStep(this.selectedStep) : Api.Queries.SelectedStep(); } assertUnreachable(type); @@ -171,6 +169,7 @@ export class ReDNATCOMsp extends React.Component<ReDNATCOMsp.Props, State> { window.dispatchEvent(new Event('resize')); else if (cmd.type === 'deselect-step') { await this.viewer.actionDeselectStep(this.state.display); + this.selectedStep = void 0; } else if (cmd.type === 'filter') { const ret = await this.viewer.actionApplyFilter(cmd.filter); if (!ret) { @@ -216,6 +215,7 @@ export class ReDNATCOMsp extends React.Component<ReDNATCOMsp.Props, State> { } viewerStepDeselected() { + this.selectedStep = void 0; this.viewer!.actionDeselectStep(this.state.display); ReDNATCOMspApi.event(Api.Events.StepDeselected()); } diff --git a/src/apps/rednatco/viewer.ts b/src/apps/rednatco/viewer.ts index 2edc54ee3cc5651f70479612f8e1159cebbdcac5..06195b5dfe445a7551bc912b79c4d9f65ce8727a 100644 --- a/src/apps/rednatco/viewer.ts +++ b/src/apps/rednatco/viewer.ts @@ -447,7 +447,7 @@ export class ReDNATCOMspViewer { ReDNATCOLociSelectionProvider, { bindings: ReDNATCOLociSelectionBindings, - onDeselected: () => interactCtx.self!.onDeselected(), + onDeselected: () => interactCtx.self!.notifyStepDeselected(), onSelected: (loci) => interactCtx.self!.onLociSelected(loci), } ), @@ -918,17 +918,21 @@ export class ReDNATCOMspViewer { await b.commit(); } - async onDeselected() { + notifyStepDeselected() { this.app.viewerStepDeselected(); } + notifyStepSelected(name: string) { + this.app.viewerStepSelected(name); + } + async onLociSelected(selected: Representation.Loci) { const loci = Loci.normalize(selected.loci, 'two-residues'); if (loci.kind === 'element-loci') { const stepDesc = Step.describe(loci, this.haveMultipleModels); if (stepDesc && this.stepNames.has(stepDesc.name)) - this.app.viewerStepSelected(stepDesc.name); + this.notifyStepSelected(stepDesc.name); } }