Skip to content

Conversation

@sekaiai
Copy link
Contributor

@sekaiai sekaiai commented Aug 6, 2025

Description

  1. 优化useVbenForm垂直布局的样式
  2. 优化formAcitons样式
  3. 增加formActions操作按钮组显示位置,默认靠右显示 actionPosition?: 'center' | 'left' | 'right';
  4. 增加formActions操作按钮组的样式 newLine: 在新行显示。rowEnd: 在行内显示,靠右对齐(默认)。inline: 使用grid默认样式 actionLayout?: 'inline' | 'newLine' | 'rowEnd';
修改前 修改后
v1 image
v3 v4

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update
  • Please, don't make changes to pnpm-lock.yaml unless you introduce a new test example.

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

  • New Features

    • Added new customization options for form action button layout and alignment.
    • Introduced a new example form demonstrating vertical layout and action button configuration.
  • Style

    • Improved spacing and alignment for form action buttons and form items.
    • Updated visual styles for form messages and button margins.
  • Documentation

    • Updated documentation to include new form action layout and position properties.

sekaiai added 7 commits August 6, 2025 14:02
- 操作按钮组显示位置
```
actionPosition?: 'center' | 'left' | 'right';
```
- 操作按钮组的样式
```
actionType?: 'block' | 'inline'
inline: 行类显示,block: 新一行单独显示
```
删除 actionType
增加 actionLayout
- actionLayout?: 'inline' | 'newLine' | 'rowEnd';
- newLine: 在新行显示。rowEnd: 在行内显示,靠右对齐(默认)。inline: 使用grid默认样式
- 删除无用代码 queryFormStyle
去掉padding,改为gap
@changeset-bot
Copy link

changeset-bot bot commented Aug 6, 2025

⚠️ No Changeset found

Latest commit: 7937b57

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 Aug 6, 2025

Walkthrough

The changes introduce new configuration options for form action button layout and alignment, updating both the form component's documentation and implementation. The form action button group now supports customizable layout (actionLayout) and alignment (actionPosition) via new props, with corresponding logic and style updates. Example usage is demonstrated in the playground. Additionally, minor style simplifications and a deduplicated search history update were included.

Changes

Cohort / File(s) Change Summary
Documentation Update
docs/src/components/common-ui/vben-form.md
Added actionLayout and actionPosition props to the form documentation, describing their possible values and defaults for configuring action button layout and alignment.
Form Action Button Layout Implementation
packages/@core/ui-kit/form-ui/src/components/form-actions.vue, packages/@core/ui-kit/form-ui/src/types.ts
Introduced actionLayout and actionPosition props in type definitions. Replaced inline styles and static classes with a computed class string for action button wrapper, enabling dynamic layout and alignment.
Form Wrapper Class Refactor
packages/@core/ui-kit/form-ui/src/form-render/form.vue
Added a computed property to generate wrapper classes dynamically, allowing responsive gap and layout styles based on props.
Form Field Style Simplification
packages/@core/ui-kit/form-ui/src/form-render/form-field.vue
Removed conditional vertical padding and bottom offset classes from form item containers and messages for a simpler layout.
Playground Example Update
playground/src/views/examples/form/query.vue
Added a new example form demonstrating vertical layout, default expanded state, and the new action button layout and alignment options.
Search History Deduplication
packages/effects/layouts/src/widgets/global-search/search-panel.vue
Modified search history update to prevent duplicate entries by filtering based on the path field when adding new search results via Enter key.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant VbenForm
    participant FormActions

    User->>VbenForm: Render form with props (actionLayout, actionPosition)
    VbenForm->>FormActions: Pass actionLayout, actionPosition
    FormActions->>FormActions: Compute actionWrapperClass based on props
    FormActions-->>VbenForm: Render action buttons with computed classes
    VbenForm-->>User: Display form with customized action button layout/alignment
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~15 minutes

Suggested reviewers

  • mynetfan
  • anncwb
  • jinmao88
  • vince292007

Poem

A form with buttons, neat and spry,
Now lines up left, or right, or nigh.
With layouts new, the fields align,
The docs refreshed, the code refined.
A bunny hops—delight in view—
For forms that flex, and layouts too!
🐇✨

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 60ff094 and 7937b57.

📒 Files selected for processing (3)
  • packages/@core/ui-kit/form-ui/src/components/form-actions.vue (2 hunks)
  • packages/@core/ui-kit/form-ui/src/form-render/form-field.vue (2 hunks)
  • packages/@core/ui-kit/form-ui/src/form-render/form.vue (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
  • packages/@core/ui-kit/form-ui/src/form-render/form-field.vue
  • packages/@core/ui-kit/form-ui/src/form-render/form.vue
  • packages/@core/ui-kit/form-ui/src/components/form-actions.vue
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: post-update (ubuntu-latest)
  • GitHub Check: post-update (windows-latest)
✨ Finishing Touches
🧪 Generate unit tests
  • 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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

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

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b93e22c and 645d2cf.

📒 Files selected for processing (6)
  • docs/src/components/common-ui/vben-form.md (1 hunks)
  • packages/@core/ui-kit/form-ui/src/components/form-actions.vue (2 hunks)
  • packages/@core/ui-kit/form-ui/src/form-render/form-field.vue (1 hunks)
  • packages/@core/ui-kit/form-ui/src/form-render/form.vue (1 hunks)
  • packages/@core/ui-kit/form-ui/src/types.ts (1 hunks)
  • playground/src/views/examples/form/query.vue (2 hunks)
🧰 Additional context used
🧠 Learnings (4)
📚 Learning: in the vue-vben-admin dialogcontent component, the animation system uses a layered approach: zoom an...
Learnt from: Elm1992
PR: vbenjs/vue-vben-admin#6537
File: packages/@core/ui-kit/shadcn-ui/src/ui/dialog/DialogContent.vue:110-114
Timestamp: 2025-07-17T16:38:41.911Z
Learning: In the Vue-Vben-Admin DialogContent component, the animation system uses a layered approach: zoom animation classes (zoom-out-95, zoom-in-95) are applied unconditionally as the base effect for scale animation, while specific animation types like 'slide' add conditional classes on top of the base effect. This design allows scale animation to use the dialog's built-in zoom effect and enables future animation types to be added without affecting the scale behavior.

Applied to files:

  • packages/@core/ui-kit/form-ui/src/form-render/form-field.vue
📚 Learning: in `docs/src/components/common-ui/vben-vxe-table.md`, the code examples are provided within markdown...
Learnt from: ArthurDarkstone
PR: vbenjs/vue-vben-admin#4807
File: docs/src/components/common-ui/vben-vxe-table.md:65-84
Timestamp: 2024-11-05T10:34:13.846Z
Learning: In `docs/src/components/common-ui/vben-vxe-table.md`, the code examples are provided within markdown scripts for documentation and do not require import statements or explicit type annotations.

Applied to files:

  • docs/src/components/common-ui/vben-form.md
📚 Learning: 在 `docs/src/components/layout-ui/page.md` 的 `page` 组件中,`title` 和 `description` 属性有意使用 `string|slot` ...
Learnt from: mynetfan
PR: vbenjs/vue-vben-admin#5013
File: docs/src/components/layout-ui/page.md:23-24
Timestamp: 2024-12-04T04:43:22.179Z
Learning: 在 `docs/src/components/layout-ui/page.md` 的 `Page` 组件中,`title` 和 `description` 属性有意使用 `string|slot` 类型表示法,表示它们可以接受字符串或插槽。

Applied to files:

  • docs/src/components/common-ui/vben-form.md
📚 Learning: 在 vben admin 项目的 `page` 组件中,`extra` 内容仅通过 slots 提供,没有对应的 prop 属性。...
Learnt from: mynetfan
PR: vbenjs/vue-vben-admin#5013
File: docs/src/components/layout-ui/page.md:31-31
Timestamp: 2024-12-04T04:41:30.161Z
Learning: 在 Vben Admin 项目的 `Page` 组件中,`extra` 内容仅通过 slots 提供,没有对应的 prop 属性。

Applied to files:

  • playground/src/views/examples/form/query.vue
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: post-update (windows-latest)
  • GitHub Check: post-update (ubuntu-latest)
🔇 Additional comments (9)
packages/@core/ui-kit/form-ui/src/types.ts (1)

357-365: LGTM! Well-defined type additions.

The new actionLayout and actionPosition properties are properly typed with clear union types and comprehensive JSDoc comments. The naming convention is consistent with existing properties and the default behaviors are well documented.

packages/@core/ui-kit/form-ui/src/form-render/form-field.vue (1)

387-387: LGTM! Simplified positioning for FormMessage.

Removing the bottom-1 class simplifies the positioning while maintaining the absolute positioning. This change aligns with the form styling optimizations mentioned in the PR objectives.

docs/src/components/common-ui/vben-form.md (1)

311-312: LGTM! Accurate documentation for new properties.

The documentation correctly reflects the new actionLayout and actionPosition properties with proper type information and default values that match the implementation.

packages/@core/ui-kit/form-ui/src/form-render/form.vue (1)

44-52: LGTM! Dynamic wrapper class computation enhances layout flexibility.

The new computed wrapperClass properly handles different layout modes and compact states with appropriate gap spacing. This improvement makes the form wrapper styling more dynamic and responsive to prop changes.

playground/src/views/examples/form/query.vue (2)

128-190: LGTM! Excellent demonstration of new form layout features.

The new QueryForm2 instance effectively showcases the new actionLayout and actionPosition properties with a practical vertical layout example. This provides clear usage guidance for the new features.


208-210: LGTM! Proper template integration for the new form example.

The template correctly integrates the new QueryForm2 with an appropriate descriptive title that explains the layout configuration.

packages/@core/ui-kit/form-ui/src/components/form-actions.vue (3)

124-124: LGTM: Improved class-based styling approach.

The change from inline styles to a class-based approach using the cn utility function is a good improvement that provides better maintainability and follows modern styling patterns.


172-172: LGTM: Valid Tailwind arbitrary value syntax for fine-tuned spacing.

The change to ml-[-0.3em] uses Tailwind's arbitrary value syntax correctly and provides more precise positioning relative to the font size.


97-97: Replace invalid col-[-2/-1] class with proper Tailwind utilities

The utility col-[-2/-1] isn’t valid Tailwind syntax. Tailwind’s grid column positioning uses col-start-{n} and col-end-{n}, with negative line numbers prefixed by a dash. To span from the second-to-last grid line to the last, use:

• col-start at –2: -col-start-2
• col-end at –1: -col-end-1

Locations to update:
• packages/@core/ui-kit/form-ui/src/components/form-actions.vue, line 97

Proposed change:

- cls.push('col-[-2/-1]');
+ cls.push('-col-start-2', '-col-end-1');

This ensures the element correctly spans the final two columns. Refer to the Tailwind grid-column docs for more details: https://v3.tailwindcss.com/docs/grid-column

Likely an incorrect or invalid review comment.

sekaiai and others added 4 commits August 6, 2025 23:07
-  props.actionLayout = props.actionLayout || 'rowEnd';
-  props.actionPosition = props.actionPosition || 'right';
+  const actionLayout = props.actionLayout || 'rowEnd';
+  const actionPosition = props.actionPosition || 'right';

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
@jinmao88 jinmao88 merged commit 9fc5944 into vbenjs:main Aug 7, 2025
4 checks passed
This was referenced Aug 15, 2025
@coderabbitai coderabbitai bot mentioned this pull request Aug 26, 2025
16 tasks
dtera pushed a commit to dtera/vue-admin that referenced this pull request Sep 5, 2025
* perf(style): 优化useVbenForm垂直布局 actions 样式

* perf(style): 优化useVbenForm actions 布局样式

- 操作按钮组显示位置
```
actionPosition?: 'center' | 'left' | 'right';
```
- 操作按钮组的样式
```
actionType?: 'block' | 'inline'
inline: 行类显示,block: 新一行单独显示
```

* perf: 优化useVbenForm actions 布局样式

删除 actionType
增加 actionLayout
- actionLayout?: 'inline' | 'newLine' | 'rowEnd';
- newLine: 在新行显示。rowEnd: 在行内显示,靠右对齐(默认)。inline: 使用grid默认样式
- 删除无用代码 queryFormStyle

* perf: 优化useVbenForm使用案例

* perf: 优化form组件样式

去掉padding,改为gap

* docs: update vben-form.md

* fix: 修复FormMessage位置

* perf: Avoid direct mutation of props object.

-  props.actionLayout = props.actionLayout || 'rowEnd';
-  props.actionPosition = props.actionPosition || 'right';
+  const actionLayout = props.actionLayout || 'rowEnd';
+  const actionPosition = props.actionPosition || 'right';

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* fix: 修复 wrapperClass 权重

* fix: 全局搜索结果不匹配 vbenjs#6603

* fix: 避免FormMessage溢出

---------

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
@github-actions github-actions bot locked and limited conversation to collaborators Sep 7, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants