-
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
fix: when multiple Tables are loaded on a page, a warning will be reported in the initialization of Tables after the second one #4791
Conversation
|
WalkthroughThe changes in the Changes
Possibly related PRs
Suggested labels
Suggested reviewers
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: 0
🧹 Outside diff range and nitpick comments (2)
packages/effects/plugins/src/vxe-table/use-vxe-grid.vue (2)
223-225
: LGTM! Clear explanation of the warning behavior.The comment effectively explains why warnings occur with multiple tables due to state caching after the first initialization.
Consider enhancing the warning message to include more context:
if (formConfig && formConfig.enabled) { console.warn( - '[Vben Vxe Table]: The formConfig in the grid is not supported, please use the `formOptions` props', + `[Vben Vxe Table]: The formConfig in the grid (${props.api?.id ?? 'unknown'}) is not supported, please use the 'formOptions' props instead. This can help identify which table instance triggered the warning.`, ); }
223-225
: Consider enhancing the migration path from formConfig to formOptions.While the warning effectively notifies developers about the deprecated
formConfig
, consider these architectural improvements:
- Add a migration guide or code examples in the warning message
- Consider implementing a development-only warning that includes stack traces
- Add runtime conversion of
formConfig
toformOptions
to ease migrationExample implementation:
// Add this helper function function convertFormConfigToOptions(formConfig: any) { // Convert old format to new format return { // Add conversion logic here // This is just an example structure fields: formConfig.items?.map((item: any) => ({ name: item.field, label: item.title, // ... other conversions })), }; } // Then in your warning block: if (formConfig && formConfig.enabled) { const converted = convertFormConfigToOptions(formConfig); console.warn( '[Vben Vxe Table]: The formConfig is deprecated. Please migrate to formOptions.\n' + 'Example migration:\n' + JSON.stringify(converted, null, 2) ); }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (1)
packages/effects/plugins/src/vxe-table/use-vxe-grid.vue
(1 hunks)
🔇 Additional comments (1)
packages/effects/plugins/src/vxe-table/use-vxe-grid.vue (1)
223-225
: Verify the impact on existing table implementations.
Let's verify the changes don't affect existing implementations and help identify areas needing migration.
✅ Verification successful
Warning handling for multiple table instances is correctly implemented
The code changes are safe and properly handle warning behavior for multiple table instances. The findings show:
- The warning is specifically for deprecating
formConfig
in favor offormOptions
- The warning logic is isolated to the
use-vxe-grid.vue
component and doesn't affect other parts of the codebase - The code ensures
formConfig.enabled
is set tofalse
in merged options, preventing unintended behavior - The comment accurately describes the caching behavior of
defaultGridOptions
andgridOptions
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Check for multiple table usage and formConfig implementations
# Test 1: Find files with multiple VxeGrid instances
echo "Files with multiple table instances:"
rg -l "VxeGrid" | while read -r file; do
count=$(rg -c "VxeGrid" "$file")
if [ "$count" -gt 1 ]; then
echo "$file: $count instances"
fi
done
# Test 2: Check for formConfig usage that needs migration
echo -e "\nFiles using formConfig that need migration:"
rg -l "formConfig:\s*{" --type vue
# Test 3: Look for any custom warning suppressions that might interfere
echo -e "\nCheck for console.warn suppressions:"
rg "console\.warn.*suppress" --type vue
Length of output: 5311
Script:
#!/bin/bash
# Let's refine our search with corrected patterns
# Test 1: Check for formConfig usage with proper regex
echo "Files using formConfig:"
rg "formConfig:" --type-add 'vue:*.vue' --type vue
# Test 2: Look for warning related code in vxe-table files
echo -e "\nWarning handling in vxe-table files:"
rg "warn" packages/effects/plugins/src/vxe-table/ -A 2 -B 2
# Test 3: Check the specific implementation in use-vxe-grid.vue
echo -e "\nContext around formConfig in use-vxe-grid.vue:"
rg "formConfig" packages/effects/plugins/src/vxe-table/use-vxe-grid.vue -A 5 -B 5
Length of output: 1942
…orted in the initialization of Tables after the second one (vbenjs#4791)
Description
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
New Features
formConfig
usage, advising the use offormOptions
.Bug Fixes
pagerConfig
andformConfig
.Documentation