From 528f475db17725f8ea58c64ba0be20a319fedea4 Mon Sep 17 00:00:00 2001 From: Alex Studer Date: Wed, 22 Nov 2023 23:05:12 -0500 Subject: [PATCH] homework/HomeworkModal: make description textbox enter behavior consistent (enter = new line, shift+enter or ctrl+enter = submit) --- app/homework/HomeworkModal.jsx | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/app/homework/HomeworkModal.jsx b/app/homework/HomeworkModal.jsx index 3696373..13ba4bd 100644 --- a/app/homework/HomeworkModal.jsx +++ b/app/homework/HomeworkModal.jsx @@ -97,14 +97,20 @@ export default function HomeworkModal(props) { ; } - const keydown = (shiftEnter) => { - return (e) => { - if (e.keyCode == 13 && !(e.shiftKey && shiftEnter)) { - save(); - e.preventDefault(); - return false; - } - }; + const keydown = (e) => { + if (e.keyCode == 13) { + save(); + e.preventDefault(); + return false; + } + }; + + const descriptionKeydown = (e) => { + if (e.keyCode == 13 && (e.shiftKey || e.ctrlKey)) { + save(); + e.preventDefault(); + return false; + } }; return @@ -114,7 +120,7 @@ export default function HomeworkModal(props) {
- setName(e.target.value)} /> + setName(e.target.value)} />
@@ -129,7 +135,7 @@ export default function HomeworkModal(props) {
- +