Add cancel edit-message on Escape Key press (#765)

This commit is contained in:
jameskitt616 2022-08-20 15:26:37 +02:00 committed by GitHub
parent 6f7934badc
commit 1deef51df0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -290,6 +290,11 @@ function MessageEdit({ body, onSave, onCancel }) {
}, []); }, []);
const handleKeyDown = (e) => { const handleKeyDown = (e) => {
if (e.key === 'Escape') {
e.preventDefault();
onCancel();
}
if (e.key === 'Enter' && e.shiftKey === false) { if (e.key === 'Enter' && e.shiftKey === false) {
e.preventDefault(); e.preventDefault();
onSave(editInputRef.current.value); onSave(editInputRef.current.value);