Skip to content

Add support for configurable label placement in AutoFormFieldWrapper#1757

Merged
rmn-snpk merged 1 commit intomainfrom
feat/add-label-placment-to-form-wrapper
Dec 10, 2025
Merged

Add support for configurable label placement in AutoFormFieldWrapper#1757
rmn-snpk merged 1 commit intomainfrom
feat/add-label-placment-to-form-wrapper

Conversation

@rmn-snpk
Copy link
Copy Markdown

@rmn-snpk rmn-snpk commented Dec 10, 2025

Part of OPS-3164.

image

Summary by CodeRabbit

New Features

  • Form field labels now support flexible positioning—labels can be placed above or to the left of input fields for improved layout customization.

✏️ Tip: You can customize this high-level summary in your review settings.

@linear
Copy link
Copy Markdown

linear Bot commented Dec 10, 2025

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Dec 10, 2025

Walkthrough

A single React component is updated to support configurable label placement through a new labelPlacement prop ('top' or 'left'). A new internal LabelContent component is introduced to consolidate label rendering. Layout logic is restructured to conditionally position labels above or beside input fields based on the placement setting.

Changes

Cohort / File(s) Summary
Label Placement Refactoring
packages/react-ui/src/app/features/builder/block-properties/auto-form-field-wrapper.tsx
Added labelPlacement prop to AutoFormFieldWrapperProps ('top' | 'left', defaults to 'top'). Introduced new internal LabelContent component for consistent label rendering. Reworked layout to support two placement modes: top (label above field) and left (label beside field). Replaced inline FormLabel usage with LabelContent-driven approach. Restructured component layout into two-block structure with conditional rendering based on placement and toggle states.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Verify label placement logic for both 'top' and 'left' modes handles spacing and alignment correctly
  • Review conditional rendering logic in LabelContent and children/dynamic input sections to ensure no edge cases
  • Confirm LabelContent component properly consolidates previous label rendering patterns
  • Validate that the two-block layout structure doesn't break existing functionality or introduce layout regressions

Poem

🐰 Labels dance left and labels dance high,
No more just one way—we've multiplied!
Top or beside, wherever you'll place,
Form fields now shimmy with newfound grace!

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Description check ⚠️ Warning The description is largely incomplete. It lacks issue details, rationale, testing information, backwards compatibility confirmation, and visual context beyond a single screenshot. Add issue number reference, explain why label placement configurability was needed, detail testing performed, confirm backwards compatibility, and provide context for the screenshot.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main change: adding configurable label placement support to AutoFormFieldWrapper.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/add-label-placment-to-form-wrapper

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.

@rmn-snpk
Copy link
Copy Markdown
Author

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Dec 10, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@sonarqubecloud
Copy link
Copy Markdown

Copy link
Copy Markdown

@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: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
packages/react-ui/src/app/features/builder/block-properties/auto-form-field-wrapper.tsx (1)

155-166: Add explicit return type for exported function.

The exported AutoFormFieldWrapper function is missing an explicit return type, which is required per the coding guidelines for TypeScript.

As per coding guidelines, use explicit return types for exported functions in TypeScript.

Apply this diff:

 const AutoFormFieldWrapper = ({
   placeBeforeLabelText = false,
   labelPlacement = 'top',
   children,
   hideDescription,
   allowDynamicValues,
   propertyName,
   inputName,
   property,
   disabled,
   field,
-}: AutoFormFieldWrapperProps) => {
+}: AutoFormFieldWrapperProps): JSX.Element => {
   const form = useFormContext();
🧹 Nitpick comments (2)
packages/react-ui/src/app/features/builder/block-properties/auto-form-field-wrapper.tsx (2)

133-153: Add explicit return type for consistency.

While the component logic is sound and consolidates label rendering effectively, consider adding an explicit return type (: JSX.Element) for better type safety and consistency with TypeScript best practices.

Apply this diff:

 const LabelContent = ({
   property,
   placeBeforeLabelText,
   dynamicViewToggled,
   children,
-}: LabelContentProps) => {
+}: LabelContentProps): JSX.Element => {
   return (

265-276: Optimize empty wrapper div.

When labelPlacement === 'left', the wrapper div (lines 266-276) contains an empty inner div, which adds an unnecessary DOM element. Consider conditionally rendering the wrapper or restructuring to avoid empty elements.

Apply this diff to remove the unnecessary wrapper:

-      <div className="flex items-center justify-between">
-        <div>
-          {labelPlacement === 'top' && (
-            <LabelContent
-              property={property}
-              placeBeforeLabelText={placeBeforeLabelText}
-              dynamicViewToggled={dynamicViewToggled}
-            >
-              {children}
-            </LabelContent>
-          )}
-        </div>
-
+      <div className="flex items-center justify-between">
+        {labelPlacement === 'top' && (
+          <LabelContent
+            property={property}
+            placeBeforeLabelText={placeBeforeLabelText}
+            dynamicViewToggled={dynamicViewToggled}
+          >
+            {children}
+          </LabelContent>
+        )}
         <FormLabelButton
           property={property}
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 689a853 and d2d954d.

📒 Files selected for processing (1)
  • packages/react-ui/src/app/features/builder/block-properties/auto-form-field-wrapper.tsx (4 hunks)
🧰 Additional context used
📓 Path-based instructions (6)
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.{ts,tsx,js,jsx}: Write clear, self-documenting code with descriptive variable and function names
Include comments for complex logic or non-obvious behavior
Require braces for all control blocks, even single-line statements
Use one space between keywords and parentheses (e.g., if (condition) {)
Use camelCase for variable and function names
Use PascalCase for class and type names
Use UPPER_SNAKE_CASE for constant names
Use lowercase with hyphens for file names (e.g., user-profile.ts)
Write comments explaining why something is done, not what (code should be self-explanatory)
Use TODO: prefix for actionable technical debt comments
Document public functions, classes, and modules
Prefer const over let or var in JavaScript/TypeScript
Prefer arrow functions for callbacks and functional components
Extract helper functions where possible

**/*.{ts,tsx,js,jsx}: Use braces for all control blocks, even single-line statements
Use one space between keywords and parentheses (e.g., 'if (condition) {')
Use camelCase for variable and function names
Use PascalCase for classes and types
Use UPPER_SNAKE_CASE for constants
Use lowercase with hyphens for file names (e.g., user-profile.ts)
Use 'TODO:' prefix for actionable technical debt comments
Prefer const over let or var in TypeScript/JavaScript
Prefer arrow functions for callbacks and functional components

Files:

  • packages/react-ui/src/app/features/builder/block-properties/auto-form-field-wrapper.tsx
**/*.{ts,tsx,js,jsx,sh}

📄 CodeRabbit inference engine (CLAUDE.md)

Use 2 spaces for indentation in TypeScript/JavaScript and shell scripts

Use 2-space indentation for TypeScript/JavaScript and shell scripts

Files:

  • packages/react-ui/src/app/features/builder/block-properties/auto-form-field-wrapper.tsx
**/*.{ts,tsx,js,jsx,json,sh,md,yml,yaml}

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.{ts,tsx,js,jsx,json,sh,md,yml,yaml}: Maintain line length of 100–120 characters
Remove trailing whitespace from all files
Ensure newline at end of file

Files:

  • packages/react-ui/src/app/features/builder/block-properties/auto-form-field-wrapper.tsx
**/*.{ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.{ts,tsx}: Use types and interfaces where appropriate in TypeScript
Use explicit return types for exported functions in TypeScript

**/*.{ts,tsx}: Use types and interfaces where appropriate in TypeScript/JavaScript
Use explicit return types for exported functions in TypeScript

Files:

  • packages/react-ui/src/app/features/builder/block-properties/auto-form-field-wrapper.tsx
packages/react-ui/**/*.{tsx,ts}

📄 CodeRabbit inference engine (CLAUDE.md)

packages/react-ui/**/*.{tsx,ts}: Use React 18 for frontend development
Use Zustand for state management
Use react-query v5 for data fetching
Use shadcn for UI components
Use Axios with the existing wrapper in api.ts and qs package for query strings
Follow React hooks best practices
Prefer small, composable React components

Files:

  • packages/react-ui/src/app/features/builder/block-properties/auto-form-field-wrapper.tsx
**/*.{tsx,jsx}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{tsx,jsx}: Use React 18 for frontend development
Follow best practices for React hooks
Prefer small, composable components
Use cn utility to group Tailwind classnames in React components

Files:

  • packages/react-ui/src/app/features/builder/block-properties/auto-form-field-wrapper.tsx
⏰ 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). (3)
  • GitHub Check: Build Engine Image for amd64
  • GitHub Check: Build Engine Image for arm64
  • GitHub Check: Build App Image for amd64
🔇 Additional comments (2)
packages/react-ui/src/app/features/builder/block-properties/auto-form-field-wrapper.tsx (2)

36-36: LGTM! Type definition follows best practices.

The new labelPlacement prop uses a clear TypeScript union type with string literals, is appropriately optional, and has a sensible default value for backward compatibility.


288-312: LGTM! Layout implementation is solid.

The two-layout approach (top vs left label placement) is implemented correctly:

  • Top placement: Label and controls in top row, input below
  • Left placement: Label and input side-by-side with proper flex properties

The conditional rendering logic correctly handles all combinations of dynamicViewToggled and placeBeforeLabelText, and the CSS classes (shrink-0, flex-1, min-w-0) ensure proper layout behavior.

@rmn-snpk rmn-snpk marked this pull request as ready for review December 10, 2025 13:06
Copilot AI review requested due to automatic review settings December 10, 2025 13:06
Copy link
Copy Markdown
Contributor

@greptile-apps greptile-apps Bot left a comment

Choose a reason for hiding this comment

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

Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds support for configurable label placement in the AutoFormFieldWrapper component, allowing labels to be positioned either above ('top') or to the left ('left') of form fields.

Key changes:

  • Introduced a new labelPlacement prop with 'top' and 'left' options
  • Extracted label rendering logic into a reusable LabelContent component
  • Restructured the layout to support both horizontal and vertical label placements

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

rmn-snpk pushed a commit that referenced this pull request Dec 10, 2025
@rmn-snpk rmn-snpk merged commit 03704c3 into main Dec 10, 2025
24 checks passed
@rmn-snpk rmn-snpk deleted the feat/add-label-placment-to-form-wrapper branch December 10, 2025 13:38
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