From eb481e374b8d99a513885c23ddf3ab08dbdf6249 Mon Sep 17 00:00:00 2001 From: jmainguytalend Date: Tue, 25 Jul 2023 10:45:01 +0200 Subject: [PATCH] Remove enter key catcher --- .../src/UIForm/fields/Code/Code.component.tsx | 32 +------------------ 1 file changed, 1 insertion(+), 31 deletions(-) diff --git a/packages/forms/src/UIForm/fields/Code/Code.component.tsx b/packages/forms/src/UIForm/fields/Code/Code.component.tsx index 8d529efa98d..3c68968c5b6 100644 --- a/packages/forms/src/UIForm/fields/Code/Code.component.tsx +++ b/packages/forms/src/UIForm/fields/Code/Code.component.tsx @@ -1,18 +1,7 @@ -import { - lazy, - DetailedHTMLProps, - KeyboardEvent, - LabelHTMLAttributes, - Suspense, - useEffect, - useRef, - useState, -} from 'react'; +import { lazy, DetailedHTMLProps, LabelHTMLAttributes, Suspense, useEffect, useState } from 'react'; import { IAceEditorProps } from 'react-ace'; import { useTranslation } from 'react-i18next'; -import { isEventKey, codes } from 'keycode'; - import assetsApi from '@talend/assets-api'; import { I18N_DOMAIN_FORMS } from '../../../constants'; @@ -89,7 +78,6 @@ export default function Code({ const descriptionId = generateDescriptionId(id); const errorId = generateErrorId(id); const instructionsId = generateId(id, 'instructions'); - const containerRef = useRef(null); const [editor, setEditor] = useState(null); useEffect(() => { @@ -100,22 +88,6 @@ export default function Code({ } }, [editor, instructionsId, descriptionId, errorId, id]); - function onKeyDown(event: KeyboardEvent) { - if (isEventKey(event.nativeEvent, codes.enter)) { - const now = Date.now(); - - if (containerRef.current.lastEsc && containerRef.current.lastEsc - now < 1000) { - containerRef.current.lastEsc = null; - containerRef.current.focus(); - editor.textInput.getElement().setAttribute('tabindex', -1); - } else { - containerRef.current.lastEsc = now; - } - } else { - containerRef.current.lastEsc = null; - } - } - function onBlur() { editor.textInput.getElement().removeAttribute('tabindex'); } @@ -136,8 +108,6 @@ export default function Code({