Skip to content

Commit

Permalink
#5205 - Edit Connection points dialog can cause invalid connection be…
Browse files Browse the repository at this point in the history
…tween monomers (#5717)

- fixed unstable test
  • Loading branch information
rrodionov91 authored Oct 11, 2024
1 parent 2fd9b23 commit 80f084a
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
4 changes: 4 additions & 0 deletions ketcher-autotests/tests/utils/clicks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,10 @@ export async function openDropdown(page: Page, dropdownElementId: DropdownIds) {
const button = page.getByTestId(dropdownElementId);
await button.isVisible();
await button.click({ delay: 200, clickCount: 2 });
const dropdown = await page.locator('.default-multitool-dropdown');
if (!(await dropdown.isVisible({ timeout: 200 }))) {
await button.click();
}
}

export async function selectDropdownTool(
Expand Down
9 changes: 1 addition & 8 deletions packages/ketcher-core/src/application/editor/Editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -326,14 +326,7 @@ export class CoreEditor {
initialFirstMonomerAttachmentPoint?: AttachmentPointName;
initialSecondMonomerAttachmentPoint?: AttachmentPointName;
}) {
if (
payload.isReconnection &&
payload.polymerBond &&
(payload.firstSelectedAttachmentPoint !==
payload.initialFirstMonomerAttachmentPoint ||
payload.secondSelectedAttachmentPoint !==
payload.initialSecondMonomerAttachmentPoint)
) {
if (payload.isReconnection && payload.polymerBond) {
const command = new Command();
const history = new EditorHistory(this);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,17 @@ const MonomerConnection = ({
throw new Error('Attachment points cannot be falsy');
}

if (
firstSelectedAttachmentPoint ===
initialFirstMonomerAttachmentPointRef.current &&
secondSelectedAttachmentPoint ===
initialSecondMonomerAttachmentPointRef.current
) {
cancelBondCreationAndClose();

return;
}

editor.events.createBondViaModal.dispatch({
firstMonomer,
secondMonomer,
Expand Down

0 comments on commit 80f084a

Please sign in to comment.