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-30 09:05:26 +00:00
committed by Copybot
parent 76dd6d1e20
commit 3a918a58e5
@@ -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]