Skip to content

Commit

Permalink
#6112 - System opens "intellisence"-like dropdown control in unnecess…
Browse files Browse the repository at this point in the history
…ary case (#6158)

* #6112 - System opens "intellisence"-like dropdown control in unnecessary case

* - update snapshots
- refactor

* - update snapshots
- refactor

---------

Co-authored-by: Zhirnoff <[email protected]>
  • Loading branch information
kostrubin and Zhirnoff authored Dec 17, 2024
1 parent 303c01b commit 790ef49
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 23 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
/* eslint-disable no-magic-numbers */
import { test, expect } from '@playwright/test';
import {
DELAY_IN_SECONDS,
clickInTheMiddleOfTheScreen,
clickOnAtom,
clickOnCanvas,
delay,
drawBenzeneRing,
moveOnAtom,
resetCurrentTool,
selectAllStructuresOnCanvas,
selectRectangleSelectionTool,
takeEditorScreenshot,
waitForPageInit,
} from '@utils';
Expand Down Expand Up @@ -182,9 +183,9 @@ test.describe('Lookup Abbreviations tests', () => {
await page.getByRole('button', { name: 'Benzene (T)' }).click();
await clickInTheMiddleOfTheScreen(page);
const atomC = 0;
await moveOnAtom(page, 'C', atomC);
await page.keyboard.type('mer');
await page.keyboard.press('Enter');
await clickOnAtom(page, 'C', atomC);
await takeEditorScreenshot(page);
});

Expand All @@ -196,25 +197,11 @@ test.describe('Lookup Abbreviations tests', () => {
await page.getByRole('button', { name: 'Benzene (T)' }).click();
await clickInTheMiddleOfTheScreen(page);
const atomC = 0;
await moveOnAtom(page, 'C', atomC);
await page.keyboard.type('bn');
await page.keyboard.press('Enter');
await takeEditorScreenshot(page);
});

test('atom state restores after typing additional letters', async ({
page,
}) => {
// EPMLSOPKET-16928
// will be added with https://github.com/epam/ketcher/issues/2789
await drawBenzeneRing(page);
const atomC = 0;
await resetCurrentTool(page);
await moveOnAtom(page, 'C', atomC);
await page.keyboard.type('n');
// 'N' should be placed on hovered atom
await page.keyboard.type('ickel');
// state of hovered atom should be restored
await clickOnAtom(page, 'C', atomC);
await selectRectangleSelectionTool(page);
await clickOnCanvas(page, 100, 100);
await takeEditorScreenshot(page);
});
});
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.
5 changes: 3 additions & 2 deletions packages/ketcher-react/src/script/ui/state/hotkeys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,9 @@ function keyHandle(dispatch, getState, hotKeys, event) {

let group: any = null;

if (key && key.length === 1) {
const hoveredItem = getHoveredItem(render.ctab);

if (key && key.length === 1 && !hoveredItem) {
const currentlyPressedKeys = selectAbbreviationLookupValue(state);
const isShortcutKey = shortcutKeys.includes(key?.toLowerCase());
const isTheSameKey = key === currentlyPressedKeys;
Expand Down Expand Up @@ -142,7 +144,6 @@ function keyHandle(dispatch, getState, hotKeys, event) {
bonds: actions['bond-props'].action,
};

const hoveredItem = getHoveredItem(render.ctab);
if (!hoveredItem) {
return;
}
Expand Down

0 comments on commit 790ef49

Please sign in to comment.