Skip to content

Commit

Permalink
#4533 - After inserting a nucleotide in the Text-editing mode, the cu…
Browse files Browse the repository at this point in the history
…rsor blinks in the wrong place (#6171)

* #4533 - After inserting a nucleotide in the Text-editing mode, the cursor blinks in the wrong place

* fix for playwright.config

* update screenshots
  • Loading branch information
Guch1g0v authored Dec 18, 2024
1 parent 02a8413 commit 54462a6
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 3 deletions.
2 changes: 1 addition & 1 deletion ketcher-autotests/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ function baseURL(): string {
const MAX_NUMBER_OF_RETRIES = 2;
// const MAX_NUMBER_OF_FAILURES = 3;
const isCI = process.env.CI_ENVIRONMENT === 'true';
var numWorkers = os.cpus().length;
let numWorkers = os.cpus().length;
if (process.env.NUM_WORKERS) {
numWorkers = Number(process.env.NUM_WORKERS);
}
Expand Down
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 @@ -1040,8 +1040,7 @@ export class SequenceMode extends BaseMode {
const currentSequence = SequenceRenderer.currentChain;

const currentSequenceHasPhosphate =
currentSequence?.lastNonEmptyNode?.monomer?.monomerItem?.props?.Name ===
'Phosphate';
currentSequence?.lastNonEmptyNode?.monomer?.isPhosphate;

let nextCaretPosition =
SequenceRenderer.caretPosition + chainsCollection.length;
Expand All @@ -1050,6 +1049,13 @@ export class SequenceMode extends BaseMode {
nextCaretPosition -= 1;
}

const hasPhosphateAtChainEnd =
chainsCollection?.lastNode?.monomer?.isPhosphate;

if (!SequenceRenderer.isCaretAtChainEnd && hasPhosphateAtChainEnd) {
nextCaretPosition -= 1;
}

const modelChanges = this.insertNewSequenceFragment(chainsCollection);

modelChanges.addOperation(new ReinitializeModeOperation());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -945,4 +945,8 @@ export class SequenceRenderer {
SequenceRenderer.chainsCollection.firstNode instanceof EmptySequenceNode
);
}

public static get isCaretAtChainEnd() {
return SequenceRenderer.currentEdittingNode instanceof EmptySequenceNode;
}
}
5 changes: 5 additions & 0 deletions packages/ketcher-core/src/domain/entities/BaseMonomer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import assert from 'assert';
import {
IKetAttachmentPoint,
IKetAttachmentPointType,
KetMonomerClass,
} from 'application/formatters/types/ket';
import { RnaSubChain } from 'domain/entities/monomer-chains/RnaSubChain';
import { ChemSubChain } from 'domain/entities/monomer-chains/ChemSubChain';
Expand Down Expand Up @@ -329,6 +330,10 @@ export abstract class BaseMonomer extends DrawingEntity {
return this.attachmentPointsToBonds[attachmentPointName] !== undefined;
}

public get isPhosphate() {
return this.monomerItem?.props?.MonomerClass === KetMonomerClass.Phosphate;
}

public get usedAttachmentPointsNamesList() {
const list: AttachmentPointName[] = [];

Expand Down

0 comments on commit 54462a6

Please sign in to comment.