Skip to content

Conversation

ming4762
Copy link
Contributor

@ming4762 ming4762 commented Aug 21, 2025

原compact模式的校验信息
image

优化后的校验信息
image

Summary by CodeRabbit

  • New Features

    • Added a compact mode for form validation messages, rendering inline beneath inputs.
    • Example playground includes a toggle to switch compact mode and a separate validate action.
  • Style

    • Adjusted form field layout and input layering for improved positioning and hover/focus behavior.
    • Simplified validation display by removing tooltip-based messaging.

Copy link

changeset-bot bot commented Aug 21, 2025

⚠️ No Changeset found

Latest commit: 0f1f4f1

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

Copy link
Contributor

coderabbitai bot commented Aug 21, 2025

Walkthrough

Removes tooltip-based validation UI in form-field, adds a compact rendering path for validation messages via a new compact prop on FormMessage, adjusts wrapper/z-index classes, and adds a playground toggle to demo compact mode.

Changes

Cohort / File(s) Summary
Form field template/layout
packages/@core/ui-kit/form-ui/src/form-render/form-field.vue
Removed CircleAlert/VbenTooltip imports and tooltip block. Changed wrapper class to relative flex-auto p-[1px]. Input gains relative hover:z-10 focus:z-10 when compact. Always render FormMessage inside Transition and pass :compact="compact".
FormMessage compact mode
packages/@core/ui-kit/shadcn-ui/src/ui/form/FormMessage.vue
Added public compact?: boolean prop (default false). Render tag is dynamic (div when compact, p otherwise). Class binding uses cn and applies vben-form-message-compact when compact. Added CSS for .vben-form-message-compact (absolute, compact positioning) while preserving non-compact visuals.
Playground example toggle
playground/src/views/examples/form/rules.vue
Added isCompact ref and a UI button to toggle it. Passes :compact="isCompact" to the Form. Split actions into “切换Compact” and “校验表单”. Commented out explicit layout: 'horizontal'.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant U as User
  participant P as Playground (rules.vue)
  participant F as FormField (form-field.vue)
  participant M as FormMessage.vue

  U->>P: Click "切换Compact" (toggle)
  P->>F: Render Form with compact = true/false
  F->>M: Render FormMessage with :compact="compact"
  alt compact = true
    Note over F,M: Compact flow — absolute, inline div under input
  else compact = false
    Note over F,M: Default flow — block p with destructive text
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • mynetfan
  • anncwb
  • jinmao88
  • vince292007

Poem

A rabbit hops through CSS and light,
Tooltips tucked and messages tight.
Compact whispers snug beneath the field,
Z-index raised — the edges healed.
I toggle, I cheer — small changes, big delight. 🐇✨

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.


📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between e4e9fc5 and 0f1f4f1.

📒 Files selected for processing (2)
  • packages/@core/ui-kit/form-ui/src/form-render/form-field.vue (3 hunks)
  • packages/@core/ui-kit/shadcn-ui/src/ui/form/FormMessage.vue (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • packages/@core/ui-kit/form-ui/src/form-render/form-field.vue
  • packages/@core/ui-kit/shadcn-ui/src/ui/form/FormMessage.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). (7)
  • GitHub Check: Test (windows-latest)
  • GitHub Check: Check (ubuntu-latest)
  • GitHub Check: Lint (windows-latest)
  • GitHub Check: Lint (ubuntu-latest)
  • GitHub Check: Check (windows-latest)
  • 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.
    • 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.
  • 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 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/Issue comments)

Type @coderabbitai help to get the list of available commands.

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

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • 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: 2

🧹 Nitpick comments (4)
packages/@core/ui-kit/shadcn-ui/src/ui/form/FormMessage.vue (2)

25-31: Avoid leaking absolute positioning via parent classes; also consider minimal a11y attributes.

The :as="props.compact ? 'div' : 'p'" and conditional classes are correct. However, since the consumer can pass classes, ensure we don't rely on parent-provided positioning. If the parent provides class="absolute" unconditionally, it will affect the non-compact path too (see form-field.vue review). Additionally, consider adding aria-live="polite" and role="alert" so screen readers announce validation changes without extra focus shifts.

Apply:

   <ErrorMessage
     :id="formMessageId"
     :name="toValue(name)"
     :as="props.compact ? 'div' : 'p'"
-    :class="
+    role="alert"
+    aria-live="polite"
+    :class="
       cn(
         'text-[0.8rem]',
         props.compact ? 'vben-form-message-compact' : 'text-destructive',
       )
     "
   />

35-50: Compact CSS: verify spacing, theming, and pointer behavior.

  • Spacing: .vben-form-message-compact has min-height: 1.5rem, but the field container padding (see form-field.vue) is pb-2 (~0.5rem) in compact mode. This is likely to cause overlap with the next row in a grid. Consider increasing bottom padding when an error is present or reduce the bubble’s min-height.
  • Theming: hard-coded color: white can clash with themes. Prefer color: hsl(var(--destructive-foreground)).
  • Pointer behavior: to avoid interfering with pointer interactions on elements below, add pointer-events: none.
 .vben-form-message-compact {
   position: absolute;
   top: 100%;
   left: 1rem;
   z-index: 1;
   width: calc(100% - 1rem);
   height: auto;
   min-height: 1.5rem;
   padding: 2px 8px;
-  color: white;
+  color: hsl(var(--destructive-foreground));
   background: hsl(var(--destructive));
   border-radius: var(--radius);
   opacity: 1;
+  pointer-events: none;
 }
packages/@core/ui-kit/form-ui/src/form-render/form-field.vue (1)

291-299: Consider dynamic bottom padding to avoid overlapping the next row in compact+error state.

Compact mode sets pb-2 (~0.5rem) on the FormItem, while the compact error bubble’s min-height is ~1.5rem. This mismatch can cause the bubble to overlap content below in grid layouts.

     :class="{
       'form-valid-error': isInValid,
       'form-is-required': shouldRequired,
       'flex-col': isVertical,
       'flex-row items-center': !isVertical,
-      'pb-4': !compact,
-      'pb-2': compact,
+      'pb-4': !compact,
+      // Increase bottom padding only when compact and invalid to reserve space for the bubble
+      'pb-2': compact && !isInValid,
+      'pb-6': compact && isInValid,
     }"

This keeps compact spacing tight in normal cases, and ensures enough room when errors are shown.

playground/src/views/examples/form/rules.vue (1)

241-248: Playground wiring LGTM; small UX suggestion.

The toggle and passing :compact="isCompact" demonstrate the feature well. For clarity, consider reflecting the state in the button text (e.g., “关闭 Compact” when active).

-        <Button @click="isCompact = !isCompact">切换Compact</Button>
+        <Button @click="isCompact = !isCompact">
+          {{ isCompact ? '关闭Compact' : '开启Compact' }}
+        </Button>
📜 Review details

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

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between ffaf85c and e4e9fc5.

📒 Files selected for processing (3)
  • packages/@core/ui-kit/form-ui/src/form-render/form-field.vue (3 hunks)
  • packages/@core/ui-kit/shadcn-ui/src/ui/form/FormMessage.vue (1 hunks)
  • playground/src/views/examples/form/rules.vue (3 hunks)
⏰ 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). (7)
  • GitHub Check: Check (windows-latest)
  • GitHub Check: Lint (windows-latest)
  • GitHub Check: Check (ubuntu-latest)
  • GitHub Check: Test (windows-latest)
  • GitHub Check: Lint (ubuntu-latest)
  • GitHub Check: post-update (ubuntu-latest)
  • GitHub Check: post-update (windows-latest)
🔇 Additional comments (4)
packages/@core/ui-kit/shadcn-ui/src/ui/form/FormMessage.vue (1)

10-17: Public compact prop addition looks good; API surface is clean.

Using withDefaults(defineProps<Props>(), { compact: false }) is straightforward and non-breaking. No concerns with the typing or defaulting.

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

324-324: Wrapper now relative: good anchor for absolute message.

Changing to class="relative flex-auto p-[1px]" correctly establishes the positioning context for the compact error bubble. Nice.

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

10-10: Default isCompact = true is fine for demo; confirm intended default.

If the goal is to showcase the optimized mode by default, this is good. Otherwise, consider defaulting to false and letting users toggle it on to compare.


24-24: Commenting out layout: 'horizontal' is OK in the playground; ensure docs are consistent.

If docs/screenshots reference horizontal layout for this example, update them to avoid confusion.

Comment on lines +369 to 371
<Transition name="slide-up">
<FormMessage :compact="compact" class="absolute" />
</Transition>
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

Bug: class="absolute" forces non-compact messages to be absolutely positioned.

FormMessage already applies absolute positioning internally in compact mode. Passing class="absolute" here unconditionally makes the non-compact version also absolute, breaking the default layout and likely causing layout shifts.

Apply this diff to let FormMessage control positioning:

-        <Transition name="slide-up">
-          <FormMessage :compact="compact" class="absolute" />
-        </Transition>
+        <Transition name="slide-up">
+          <FormMessage :compact="compact" />
+        </Transition>
📝 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
<Transition name="slide-up">
<FormMessage :compact="compact" class="absolute" />
</Transition>
<Transition name="slide-up">
<FormMessage :compact="compact" />
</Transition>
🤖 Prompt for AI Agents
In packages/@core/ui-kit/form-ui/src/form-render/form-field.vue around lines 369
to 371, the FormMessage is being forced to absolute positioning by passing
class="absolute" unconditionally; remove that hardcoded class (or change it to
only apply when compact is true) so FormMessage can control its own positioning
internally — e.g. delete the class="absolute" attribute or replace it with a
conditional class bound to the compact prop so only compact messages become
absolute.

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.

1 participant