-
Notifications
You must be signed in to change notification settings - Fork 7.8k
feat: 支持useVbenForm的dependencies.triggerFields为嵌套字段 #6296
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
base: main
Are you sure you want to change the base?
Conversation
WalkthroughThe change updates the dependencies logic in the form rendering utility to support accessing nested field values in Changes
Sequence Diagram(s)sequenceDiagram
participant FormComponent
participant useDependencies
participant getNestedValue
FormComponent->>useDependencies: Provide form values and dependencies
useDependencies->>useDependencies: Iterate over triggerFields
alt Field is nested (contains '.')
useDependencies->>getNestedValue: Retrieve nested value
getNestedValue-->>useDependencies: Return nested field value
else Field is top-level
useDependencies->>useDependencies: Access value directly
end
useDependencies-->>FormComponent: Return computed triggerFieldValues
Assessment against linked issues
Possibly related issues
Suggested reviewers
Poem
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. 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: 0
🧹 Nitpick comments (1)
packages/@core/ui-kit/form-ui/src/form-render/dependencies.ts (1)
40-45
: Good implementation with minor edge case consideration.The nested field access implementation is well-structured and maintains backward compatibility. The Chinese comment clearly explains the new functionality.
However, consider adding error handling for edge cases:
return triggerFields.map((dep) => { + // Validate dependency field name + if (typeof dep !== 'string' || dep.length === 0) { + console.warn(`Invalid dependency field name: ${dep}`); + return undefined; + } // 支持嵌套字段访问,如 'config.name' if (dep.includes('.')) { - return getNestedValue(values.value, dep); + try { + return getNestedValue(values.value, dep); + } catch (error) { + console.warn(`Failed to access nested field '${dep}':`, error); + return undefined; + } } return values.value[dep]; });This adds resilience against invalid field names and provides helpful debugging information without breaking the form functionality.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
packages/@core/ui-kit/form-ui/src/form-render/dependencies.ts
(2 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
packages/@core/ui-kit/form-ui/src/form-render/dependencies.ts (1)
packages/@core/base/shared/src/utils/util.ts (1)
getNestedValue
(27-44)
⏰ Context from checks skipped due to timeout of 90000ms (6)
- GitHub Check: Check (windows-latest)
- GitHub Check: Check (ubuntu-latest)
- GitHub Check: Test (windows-latest)
- GitHub Check: Analyze (javascript-typescript)
- GitHub Check: post-update (ubuntu-latest)
- GitHub Check: post-update (windows-latest)
🔇 Additional comments (1)
packages/@core/ui-kit/form-ui/src/form-render/dependencies.ts (1)
9-9
: LGTM! Import statement correctly updated.The addition of
getNestedValue
to the imports is necessary for the new nested field functionality.
|
根据AI提示 有可以优化的地方 |
Description
close #6273
Type of change
Please delete options that are not relevant.
pnpm-lock.yaml
unless you introduce a new test example.Checklist
pnpm run docs:dev
command.pnpm test
.feat:
,fix:
,perf:
,docs:
, orchore:
.Summary by CodeRabbit