Skip to content

Commit

Permalink
#5231 - Canvas should remain in edit mode if we insert monomer from t…
Browse files Browse the repository at this point in the history
…he library (#6146)
  • Loading branch information
rrodionov91 authored Dec 13, 2024
1 parent 892fe60 commit 658a284
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 6 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -847,12 +847,7 @@ export class SequenceMode extends BaseMode {
),
],
handler: (event) => {
if (
SequenceRenderer.chainsCollection.length === 1 &&
SequenceRenderer.chainsCollection.firstNode instanceof
EmptySequenceNode &&
!this.isEditMode
) {
if (SequenceRenderer.isEmptyCanvas() && !this.isEditMode) {
this.turnOnEditMode();
SequenceRenderer.setCaretPosition(0);
}
Expand Down Expand Up @@ -1393,6 +1388,7 @@ export class SequenceMode extends BaseMode {
const history = new EditorHistory(editor);
const modelChanges = new Command();
const selections = SequenceRenderer.selections;
const wasCanvasEmptyBeforeInsertion = SequenceRenderer.isEmptyCanvas();

if (selections.length > 0) {
if (
Expand Down Expand Up @@ -1465,6 +1461,11 @@ export class SequenceMode extends BaseMode {
SequenceRenderer.moveCaretForward();
history.update(modelChanges);
}

if (wasCanvasEmptyBeforeInsertion) {
this.turnOnEditMode();
SequenceRenderer.moveCaretForward();
}
}

private createRnaPresetNode(preset: IRnaPreset, position: Vec2) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -938,4 +938,11 @@ export class SequenceRenderer {
newSequenceButton.show();
this.newSequenceButtons.push(newSequenceButton);
}

public static isEmptyCanvas() {
return (
SequenceRenderer.chainsCollection.length === 1 &&
SequenceRenderer.chainsCollection.firstNode instanceof EmptySequenceNode
);
}
}

0 comments on commit 658a284

Please sign in to comment.