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:
committed by
Copybot
parent
76dd6d1e20
commit
3a918a58e5
+3
-1
@@ -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]
|
||||
|
||||
Reference in New Issue
Block a user