From 892fe60d02afa2eb406a194e4fd9a2dd6e420403 Mon Sep 17 00:00:00 2001 From: Roman Rodionov Date: Fri, 13 Dec 2024 11:31:11 +0100 Subject: [PATCH] #5139 - After pressing the Clear Canvas button in sequence-editing view, the Enter button does not start a new sequence but erases it (#6145) #4338 - After Undo/Redo actions Enter repeats these actions. --- .../src/components/menu/menuItem/MenuItem.tsx | 3 +++ packages/ketcher-macromolecules/src/helpers/canvas.ts | 5 +++++ 2 files changed, 8 insertions(+) create mode 100644 packages/ketcher-macromolecules/src/helpers/canvas.ts diff --git a/packages/ketcher-macromolecules/src/components/menu/menuItem/MenuItem.tsx b/packages/ketcher-macromolecules/src/components/menu/menuItem/MenuItem.tsx index 1c32725bdf..f7d5620bdf 100644 --- a/packages/ketcher-macromolecules/src/components/menu/menuItem/MenuItem.tsx +++ b/packages/ketcher-macromolecules/src/components/menu/menuItem/MenuItem.tsx @@ -17,6 +17,7 @@ import { type IconName } from 'ketcher-react'; import { useMenuContext } from '../../../hooks/useMenuContext'; import { useCallback } from 'react'; import { StyledIconButton } from './styles'; +import { blurActiveElement } from 'helpers/canvas'; type MenuItemProp = { itemId: IconName; @@ -37,6 +38,8 @@ const MenuItem = ({ const onClickCallback = useCallback(() => { activate(itemId); + blurActiveElement(); + if (onClick) { onClick(); } diff --git a/packages/ketcher-macromolecules/src/helpers/canvas.ts b/packages/ketcher-macromolecules/src/helpers/canvas.ts new file mode 100644 index 0000000000..658f631038 --- /dev/null +++ b/packages/ketcher-macromolecules/src/helpers/canvas.ts @@ -0,0 +1,5 @@ +export function blurActiveElement() { + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore + document.activeElement?.blur(); +}