-
Notifications
You must be signed in to change notification settings - Fork 8.6k
fix: 当 showToolbar 为 false 时禁用工具栏(vxe-table),减少无 Toolbar 的 Gird 留白 #7516
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
Conversation
|
📝 WalkthroughWalkthroughA single-line change in the vxe-grid toolbar computation now explicitly sets Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~2 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches🧪 Generate unit tests (beta)
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. Comment |
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
🤖 Fix all issues with AI agents
In `@packages/effects/plugins/src/vxe-table/use-vxe-grid.vue`:
- Around line 167-169: The current early return disables the toolbar whenever
showToolbar.value is false, which misses cases where toolbarConfig.tools (from
gridOptions.toolbarConfig.tools) contains user-provided tools; update the guard
in use-vxe-grid (where showToolbar and toolbarConfig are used) to only disable
the toolbar if there is truly no content — i.e., check both showToolbar.value
and that toolbarConfig.tools is empty/undefined before setting
toolbarConfig.enabled = false and returning; ensure the logic references
toolbarConfig.tools (and gridOptions.toolbarConfig.tools) so configured tools
keep the toolbar visible.
| if (!showToolbar.value) { | ||
| toolbarConfig.enabled = false; | ||
| return { toolbarConfig }; |
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.
🧩 Analysis chain
🏁 Script executed:
cat -n packages/effects/plugins/src/vxe-table/use-vxe-grid.vue | head -200Repository: vbenjs/vue-vben-admin
Length of output: 6563
🏁 Script executed:
# Get more context around lines 167-169 to verify the complete logic
sed -n '140,180p' packages/effects/plugins/src/vxe-table/use-vxe-grid.vue | cat -nRepository: vbenjs/vue-vben-admin
Length of output: 1579
Avoid disabling toolbar when tools are configured.
showToolbar only checks for slots and table title, ignoring toolbarConfig.tools. When users provide tools via gridOptions.toolbarConfig.tools but without any toolbar slots or table title, the toolbar gets disabled despite having configured content, hiding user actions and the search toggle. Gate the disable on actual toolbar content.
🔧 Proposed fix (guard with tools presence)
- if (!showToolbar.value) {
+ const hasToolbarContent =
+ showToolbar.value ||
+ (Array.isArray(toolbarConfig.tools) && toolbarConfig.tools.length > 0);
+
+ if (!hasToolbarContent) {
toolbarConfig.enabled = false;
return { toolbarConfig };
}📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| if (!showToolbar.value) { | |
| toolbarConfig.enabled = false; | |
| return { toolbarConfig }; | |
| const hasToolbarContent = | |
| showToolbar.value || | |
| (Array.isArray(toolbarConfig.tools) && toolbarConfig.tools.length > 0); | |
| if (!hasToolbarContent) { | |
| toolbarConfig.enabled = false; | |
| return { toolbarConfig }; |
🤖 Prompt for AI Agents
In `@packages/effects/plugins/src/vxe-table/use-vxe-grid.vue` around lines 167 -
169, The current early return disables the toolbar whenever showToolbar.value is
false, which misses cases where toolbarConfig.tools (from
gridOptions.toolbarConfig.tools) contains user-provided tools; update the guard
in use-vxe-grid (where showToolbar and toolbarConfig are used) to only disable
the toolbar if there is truly no content — i.e., check both showToolbar.value
and that toolbarConfig.tools is empty/undefined before setting
toolbarConfig.enabled = false and returning; ensure the logic references
toolbarConfig.tools (and gridOptions.toolbarConfig.tools) so configured tools
keep the toolbar visible.
|
this should be "fix" not "refactor" |
ok, I have modified the commit message |
Description
当 showToolbar 为 false 时禁用工具栏,减少无 Toolbar 的 Gird 留白

Type of change
Please delete options that are not relevant.
Checklist
pnpm run docs:devcommand.pnpm test.feat:,fix:,perf:,docs:, orchore:.Summary by CodeRabbit