Prevent submitting comment on enter if input is empty (#23221)

* Prevent submitting comment on enter if input is empty

* check for content in keyPress event

GitOrigin-RevId: 1abef229782265836a49d74aa93625797d50dc3a
This commit is contained in:
Domagoj Kriskovic
2025-01-29 15:32:53 +01:00
committed by Copybot
parent 7d2a2b78ee
commit 681d6d8192

View File

@@ -12,7 +12,9 @@ export default function useSubmittableTextInput(
(e: React.KeyboardEvent<HTMLTextAreaElement>) => {
if (e.key === 'Enter' && !e.shiftKey && !e.ctrlKey && !e.metaKey) {
e.preventDefault()
handleSubmit(content, setContent)
if (content.trim().length > 0) {
handleSubmit(content, setContent)
}
}
},
[content, handleSubmit]