From 35198a3abb75f95a169e3e29e6c64ae43529eccf Mon Sep 17 00:00:00 2001 From: cristhianzl Date: Tue, 19 Mar 2024 15:00:46 -0300 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20(codeAreaModal/index.tsx):=20add=20?= =?UTF-8?q?event=20listener=20to=20prevent=20the=20Escape=20key=20from=20c?= =?UTF-8?q?losing=20the=20modal=20=F0=9F=93=9D=20(codeAreaModal/index.tsx)?= =?UTF-8?q?:=20improve=20code=20readability=20by=20adding=20line=20breaks?= =?UTF-8?q?=20and=20indentation=20for=20better=20code=20organization?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/modals/codeAreaModal/index.tsx | 140 +++++++++--------- 1 file changed, 74 insertions(+), 66 deletions(-) diff --git a/src/frontend/src/modals/codeAreaModal/index.tsx b/src/frontend/src/modals/codeAreaModal/index.tsx index e68592efa..2766853f8 100644 --- a/src/frontend/src/modals/codeAreaModal/index.tsx +++ b/src/frontend/src/modals/codeAreaModal/index.tsx @@ -146,75 +146,83 @@ export default function CodeAreaModal({ setCode(value); }, [value, open]); + const handlePreventEsc = (e: React.KeyboardEvent) => { + if (e.key === "Escape") { + e.preventDefault(); + } + }; + return ( - - {children} - - {EDIT_CODE_TITLE} - - - -
-
- { - setCode(value); - }} - className="h-full w-full rounded-lg border-[1px] border-gray-300 custom-scroll dark:border-gray-600" - /> -
-
-
-

- {error?.detail?.error} -

-
- - {error?.detail?.traceback} - +
handlePreventEsc(e)}> + + {children} + + {EDIT_CODE_TITLE} + + + +
+
+ { + setCode(value); + }} + className="h-full w-full rounded-lg border-[1px] border-gray-300 custom-scroll dark:border-gray-600" + /> +
+
+
+

+ {error?.detail?.error} +

+
+ + {error?.detail?.traceback} + +
+
+ +
-
- -
-
- - + + +
); }