From 646598afba45fdab910f5a3f85a99ac993df5428 Mon Sep 17 00:00:00 2001 From: Svend Date: Sun, 20 Oct 2024 21:07:34 +0800 Subject: [PATCH] fix(@vben-core/form-ui): fix the issue of Textarea not being able to wrap lines in the form (#4691) --- packages/@core/ui-kit/form-ui/src/vben-use-form.vue | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/packages/@core/ui-kit/form-ui/src/vben-use-form.vue b/packages/@core/ui-kit/form-ui/src/vben-use-form.vue index bf06a0735f3..8926232ff51 100644 --- a/packages/@core/ui-kit/form-ui/src/vben-use-form.vue +++ b/packages/@core/ui-kit/form-ui/src/vben-use-form.vue @@ -39,7 +39,14 @@ const handleUpdateCollapsed = (value: boolean) => { props.formApi?.setState({ collapsed: !!value }); }; -function handleKeyDownEnter() { +function handleKeyDownEnter(event: KeyboardEvent) { + // 如果是 textarea 不阻止默认行为,否则会导致无法换行。 + // 跳过 textarea 的回车提交处理 + if (event.target instanceof HTMLTextAreaElement) { + return; + } + event.preventDefault(); + if (!state.value.submitOnEnter || !formActionsRef.value) { return; } @@ -49,7 +56,7 @@ function handleKeyDownEnter() {