From 0bbe6a0a12e9a38a5a56c88f6ac3643e51c50f5d Mon Sep 17 00:00:00 2001 From: Ajay Bura Date: Mon, 13 Sep 2021 16:30:23 +0530 Subject: [PATCH] Save edited message on enter (#78) --- src/app/molecules/message/Message.jsx | 9 +++++++++ src/app/organisms/profile-editor/ProfileEditor.jsx | 1 - 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/app/molecules/message/Message.jsx b/src/app/molecules/message/Message.jsx index c1da0f0..440197b 100644 --- a/src/app/molecules/message/Message.jsx +++ b/src/app/molecules/message/Message.jsx @@ -128,10 +128,19 @@ MessageContent.propTypes = { function MessageEdit({ content, onSave, onCancel }) { const editInputRef = useRef(null); + + function handleKeyDown(e) { + if (e.keyCode === 13 && e.shiftKey === false) { + e.preventDefault(); + onSave(editInputRef.current.value); + } + } + return (
{ e.preventDefault(); onSave(editInputRef.current.value); }}>