-
Notifications
You must be signed in to change notification settings - Fork 7.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add submitOnChange props to vben form #5032
Conversation
|
WalkthroughThe pull request introduces the Changes
Assessment against linked issues
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
Warning There were issues while running some tools. Please review the errors and either fix the tool’s configuration or disable the tool if it’s a critical failure. 🔧 eslint
docs/src/demos/vben-vxe-table/form/index.vueOops! Something went wrong! :( ESLint: 9.16.0 Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/node_modules/@vben/eslint-config/dist/index.mjs' imported from /eslint.config.mjs Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Outside diff range and nitpick comments (3)
packages/@core/ui-kit/form-ui/src/vben-use-form.vue (1)
62-68
: Consider making debounce time configurable and adding error handlingWhile the implementation is solid, consider these improvements:
- Make the debounce time configurable through props to support different use cases
- Add error handling for the submission callback
Consider this enhancement:
interface Props extends VbenFormProps { formApi: ExtendedFormApi; + submitDebounceMs?: number; } watch( () => form.values, useDebounceFn(() => { - state.value.submitOnChange && props.formApi?.submitForm(); + if (!state.value.submitOnChange) return; + try { + props.formApi?.submitForm(); + } catch (error) { + console.error('Auto-submission failed:', error); + } - }, 300), + }, props.submitDebounceMs ?? 300), { deep: true }, );packages/@core/ui-kit/form-ui/src/types.ts (1)
345-349
: LGTM! Consider enhancing documentation.The
submitOnChange
property is well-defined with appropriate type and documentation.Consider adding examples in the JSDoc comment to illustrate common use cases, such as:
/** * 是否在字段值改变时提交表单 * @default false + * @example + * // Auto-submit on field changes + * submitOnChange: true + * + * // Manual submit only (default) + * submitOnChange: false */docs/src/components/common-ui/vben-form.md (1)
319-319
: Enhance documentation with usage examples.The
submitOnChange
property is well-documented in the Props table, but could benefit from additional examples.Consider adding a dedicated example section showing:
- Basic usage with auto-submission
- Integration with form validation
- Performance considerations with debouncing
Example addition:
| submitOnChange | 字段值改变时提交表单 | `boolean` | false | + +### 自动提交示例 + +```vue +<script setup lang="ts"> +import { useVbenForm } from '#/adapter/form'; + +const [Form, formApi] = useVbenForm({ + submitOnChange: true, + handleSubmit: async (values) => { + console.log('Form submitted with values:', values); + } +}); +</script> +```
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (6)
docs/src/components/common-ui/vben-form.md
(1 hunks)docs/src/demos/vben-vxe-table/form/index.vue
(1 hunks)packages/@core/ui-kit/form-ui/src/form-api.ts
(1 hunks)packages/@core/ui-kit/form-ui/src/types.ts
(1 hunks)packages/@core/ui-kit/form-ui/src/vben-use-form.vue
(2 hunks)playground/src/views/examples/vxe-table/form.vue
(1 hunks)
🔇 Additional comments (4)
playground/src/views/examples/vxe-table/form.vue (1)
68-69
: LGTM! Clear example implementation of submitOnChange
The implementation correctly demonstrates the new submitOnChange
feature with proper documentation.
docs/src/demos/vben-vxe-table/form/index.vue (1)
79-80
: LGTM! Good documentation example with default behavior
The implementation correctly shows the default behavior with submitOnChange: false
, providing a good contrast to the playground example.
packages/@core/ui-kit/form-ui/src/vben-use-form.vue (1)
9-11
: LGTM! Clean import organization
The imports are well-organized, separating Vue core, utility functions, and component imports.
packages/@core/ui-kit/form-ui/src/form-api.ts (1)
39-39
: LGTM! Default state properly initialized.
The submitOnChange
property is correctly initialized to false
in the default state, matching the interface definition.
Description
在vben form 中添加 submitOnChange 属性用以控制是否在字段改变时提交查询。close: #5031
Type of change
Please delete options that are not relevant.
pnpm-lock.yaml
unless you introduce a new test example.Summary by CodeRabbit
New Features
submitOnChange
property for forms, allowing automatic submission when field values change.Bug Fixes
Documentation