Skip to content

Commit

Permalink
#2982 – Ignore abbreviation lookup for repetitive keystrokes
Browse files Browse the repository at this point in the history
  • Loading branch information
Nitvex committed Jul 27, 2023
1 parent e20fd02 commit ad55698
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion packages/ketcher-react/src/script/ui/state/hotkeys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ function removeNotRenderedStruct(actionTool, group, dispatch) {

let abbreviationLookupTimeoutId: number | undefined;
const ABBREVIATION_LOOKUP_TYPING_TIMEOUT = 1000;
const shortcutKeys = ['1', 't'];

/* HotKeys */
function keyHandle(dispatch, getState, hotKeys, event) {
Expand All @@ -76,7 +77,12 @@ function keyHandle(dispatch, getState, hotKeys, event) {
let group: any = null;

if (key && key.length === 1) {
if (selectAbbreviationLookupValue(state)) {
const currentlyPressedKeys = selectAbbreviationLookupValue(state);
const isShortcutKey = shortcutKeys.includes(key?.toLowerCase());
const isTheSameKey = key === currentlyPressedKeys;
const isAbbreviationLookupShown =
(!isTheSameKey || !isShortcutKey) && currentlyPressedKeys;
if (isAbbreviationLookupShown) {
dispatch(showAbbreviationLookup(event.key));
clearTimeout(abbreviationLookupTimeoutId);
abbreviationLookupTimeoutId = undefined;
Expand Down

0 comments on commit ad55698

Please sign in to comment.