From 65b0b0d819be917623bc2cc6173c2b4e8b44fe3a Mon Sep 17 00:00:00 2001 From: Paulo Gustavo Veiga Date: Wed, 6 Apr 2022 08:53:33 -0300 Subject: [PATCH] Fix missing key on Firefox. --- .../src/components/DesignerKeyboard.ts | 23 ++++++++++--------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/packages/mindplot/src/components/DesignerKeyboard.ts b/packages/mindplot/src/components/DesignerKeyboard.ts index 9febc553..22dba459 100644 --- a/packages/mindplot/src/components/DesignerKeyboard.ts +++ b/packages/mindplot/src/components/DesignerKeyboard.ts @@ -33,7 +33,7 @@ class DesignerKeyboard extends Keyboard { private static _disabled: boolean; - private static excludeFromEditor = ['Escape', 'F1', 'F3', 'F4', 'F5', 'F6', 'F7', 'F8', 'F9', 'F10', 'F11', 'F12']; + private static excludeFromEditor = ['Enter', 'CapsLock', 'Escape', 'F1', 'F3', 'F4', 'F5', 'F6', 'F7', 'F8', 'F9', 'F10', 'F11', 'F12']; constructor(designer: Designer) { super(); @@ -164,16 +164,17 @@ class DesignerKeyboard extends Keyboard { return; } - // Should I open the editor ? - if (!['Enter', 'CapsLock'].includes(event.code)) { - const nodes = designer.getModel().filterSelectedTopics(); - if (nodes.length > 0) { - // If a modifier is press, the key selected must be ignored. - if (event.ctrlKey || event.altKey || event.metaKey) { - return; - } - nodes[0].showTextEditor(''); - } + // Is a modifier ? + if (event.ctrlKey || event.altKey || event.metaKey) { + return; + } + + // If a node is selected, open the editor ... + const topic = designer.getModel().selectedTopic(); + if (topic) { + event.stopPropagation(); + event.preventDefault(); + topic.showTextEditor(event.key); } }); }