Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
monorepo
/
venus
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
1
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 181e3873
authored
Dec 17, 2024
by
Netfan
Committed by
GitHub
Dec 17, 2024
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
fix: form auto submit no effect when showDefaultActions is false (#5163)
1 parent
4fe44611
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
11 deletions
packages/@core/ui-kit/form-ui/src/vben-use-form.vue
packages/@core/ui-kit/form-ui/src/vben-use-form.vue
View file @
181e387
...
...
@@ -6,7 +6,7 @@ import type { ExtendedFormApi, VbenFormProps } from './types';
import
{
useForwardPriorityValues
}
from
'@vben-core/composables'
;
// import { isFunction } from '@vben-core/shared/utils';
import
{
nextTick
,
onMounted
,
useTemplateRef
,
watch
}
from
'vue'
;
import
{
nextTick
,
onMounted
,
watch
}
from
'vue'
;
import
{
cloneDeep
}
from
'@vben-core/shared/utils'
;
...
...
@@ -27,8 +27,6 @@ interface Props extends VbenFormProps {
const
props
=
defineProps
<
Props
>
();
const
formActionsRef
=
useTemplateRef
<
typeof
FormActions
>
(
'formActionsRef'
);
const
state
=
props
.
formApi
?.
useStore
?.();
const
forward
=
useForwardPriorityValues
(
props
,
state
);
...
...
@@ -44,11 +42,7 @@ const handleUpdateCollapsed = (value: boolean) => {
};
function
handleKeyDownEnter
(
event
:
KeyboardEvent
)
{
if
(
!
state
.
value
.
submitOnEnter
||
!
formActionsRef
.
value
||
!
formActionsRef
.
value
.
handleSubmit
)
{
if
(
!
state
.
value
.
submitOnEnter
||
!
forward
.
value
.
formApi
?.
isMounted
)
{
return
;
}
// 如果是 textarea 不阻止默认行为,否则会导致无法换行。
...
...
@@ -58,12 +52,12 @@ function handleKeyDownEnter(event: KeyboardEvent) {
}
event
.
preventDefault
();
for
mActionsRef
.
value
?.
handleSubmit
?.
();
for
ward
.
value
.
formApi
.
validateAndSubmitForm
();
}
const
handleValuesChangeDebounced
=
useDebounceFn
((
newVal
)
=>
{
forward
.
value
.
handleValuesChange
?.(
cloneDeep
(
newVal
));
state
.
value
.
submitOnChange
&&
for
mActionsRef
.
value
?.
handleSubmit
?.
();
state
.
value
.
submitOnChange
&&
for
ward
.
value
.
formApi
?.
validateAndSubmitForm
();
},
300
);
onMounted
(
async
()
=>
{
...
...
@@ -94,7 +88,6 @@ onMounted(async () => {
<slot
v-bind=
"slotProps"
>
<FormActions
v-if=
"forward.showDefaultActions"
ref=
"formActionsRef"
:model-value=
"state.collapsed"
@
update:model-value=
"handleUpdateCollapsed"
>
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment