Skip to content

Conversation

@MrLeo
Copy link
Contributor

@MrLeo MrLeo commented Feb 4, 2026

Description

当 showToolbar 为 false 时禁用工具栏,减少无 Toolbar 的 Gird 留白
image

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)

Checklist

ℹ️ Check all checkboxes - this will indicate that you have done everything in accordance with the rules in CONTRIBUTING.

  • If you introduce new functionality, document it. You can run documentation with pnpm run docs:dev command.
  • Run the tests with pnpm test.
  • Changes in changelog are generated from PR name. Please, make sure that it explains your changes in an understandable manner. Please, prefix changeset messages with feat:, fix:, perf:, docs:, or chore:.
  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

Summary by CodeRabbit

  • Bug Fixes
    • Ensures the toolbar is explicitly disabled when it should not be shown, preventing hidden toolbar controls from remaining active or affecting layout and interactions. This fixes visual/state inconsistencies and improves reliability when toolbar display is toggled.

@changeset-bot
Copy link

changeset-bot bot commented Feb 4, 2026

⚠️ No Changeset found

Latest commit: 6fd426d

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 4, 2026

📝 Walkthrough

Walkthrough

A single-line change in the vxe-grid toolbar computation now explicitly sets toolbarConfig.enabled = false when showToolbar is false, ensuring the toolbar is explicitly disabled instead of relying on implicit defaults.

Changes

Cohort / File(s) Summary
Toolbar Configuration
packages/effects/plugins/src/vxe-table/use-vxe-grid.vue
When showToolbar is false, assigns toolbarConfig.enabled = false before returning to explicitly disable the toolbar.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

Possibly related PRs

Suggested reviewers

  • anncwb
  • vince292007
  • mynetfan

Poem

🐰 A small change, a gentle hop,
One line tells the toolbar: stop.
No more guessing, clear and bright,
Disabled now, snug and right. 🥕

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main change: disabling the toolbar when showToolbar is false to reduce whitespace in grids without a toolbar in vxe-table.
Description check ✅ Passed The description follows the required template with a clear description, identifies it as a bug fix, and completes all checklist items, though it lacks detailed technical explanation of the implementation.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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.

Comment on lines 167 to 169
if (!showToolbar.value) {
toolbarConfig.enabled = false;
return { toolbarConfig };
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

cat -n packages/effects/plugins/src/vxe-table/use-vxe-grid.vue | head -200

Repository: 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 -n

Repository: 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.

Suggested change
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.

@MrLeo MrLeo changed the title vxe-table: 当 showToolbar 为 false 时禁用工具栏,减少无 Toolbar 的 Gird 留白 refactor: 当 showToolbar 为 false 时禁用工具栏(vxe-table),减少无 Toolbar 的 Gird 留白 Feb 4, 2026
@doraemonxxx
Copy link

this should be "fix" not "refactor"

@MrLeo MrLeo changed the title refactor: 当 showToolbar 为 false 时禁用工具栏(vxe-table),减少无 Toolbar 的 Gird 留白 fix: 当 showToolbar 为 false 时禁用工具栏(vxe-table),减少无 Toolbar 的 Gird 留白 Feb 4, 2026
@MrLeo
Copy link
Contributor Author

MrLeo commented Feb 4, 2026

this should be "fix" not "refactor"

ok, I have modified the commit message

@jinmao88 jinmao88 merged commit 8f4f27d into vbenjs:main Feb 6, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants