Skip to content

Commit

Permalink
feat: disable submit on keypress in textarea
Browse files Browse the repository at this point in the history
  • Loading branch information
jeanvier committed Feb 22, 2024
1 parent 46d9dd7 commit 05dfea2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions playground/app.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
/>
<FormInput label="" type="checkbox" name="tosnlpd" :rules="[{ equals: [true], message: 'coucou' }]" />
<FormInput name="safs" :rules="['isNotEmpty']" />
<FormTextarea name="saffs" :rules="['isNotEmpty']" />
<FormSubmit>
Submit
</FormSubmit>
Expand Down
6 changes: 3 additions & 3 deletions src/runtime/components/FormSubmit.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ const submit = async () => {
onMounted(() => {
document.addEventListener('keypress', function (event) {
if (event.key === 'Enter') {
event.preventDefault();
if (event.key === 'Enter' && (event.target as Element)?.tagName !== 'TEXTAREA') {
event.preventDefault()
submit()
}
});
})
})
</script>
Expand Down

0 comments on commit 05dfea2

Please sign in to comment.