Skip to content

Fix: adjust spacing in RadioGroupItemField label for better a11y#136

Merged
jaruesink merged 3 commits intomainfrom
fix/radio-group-spacing
Sep 18, 2025
Merged

Fix: adjust spacing in RadioGroupItemField label for better a11y#136
jaruesink merged 3 commits intomainfrom
fix/radio-group-spacing

Conversation

@lcmohsen
Copy link
Copy Markdown
Contributor

@lcmohsen lcmohsen commented Sep 8, 2025

As you can see in the image, adding margin to create space between the element and its label causes an issue: the user can’t click the label when the cursor is in that small gap between the two elements.

image

Summary by CodeRabbit

  • Style

    • Adjusted radio item layout by removing the horizontal gap between item and label and adding left padding to the label for cleaner alignment and improved readability; no behavioral or accessibility changes.
  • Chores

    • Bumped components package version (0.19.5 → 0.19.6).

@bolt-new-by-stackblitz
Copy link
Copy Markdown

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Sep 8, 2025

Walkthrough

Removed the wrapper horizontal gap between the radio input and label in RadioGroupItemField and moved the spacing to the label via left padding; bumped package version from 0.19.5 to 0.19.6. No behavioral/API changes.

Changes

Cohort / File(s) Change Summary
Styling tweak: radio item spacing
packages/components/src/ui/radio-group-item-field.tsx
Removed wrapper space-x-2; added pl-2 to the label's className. No logic changes.
Package version bump
packages/components/package.json
Updated version from 0.19.5 to 0.19.6. No other fields changed.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Pre-merge checks (2 passed, 1 warning)

❌ Failed Checks (1 warning)
Check Name Status Explanation Resolution
Description Check ⚠️ Warning The description demonstrates the accessibility problem and includes an illustrative image but fails to detail the actual changes introduced (removing the wrapper gap, adding label padding), the rationale behind that implementation, or any testing and verification steps, leaving reviewers without full context. Update the description to summarize the specific style adjustments made, explain how they resolve the accessibility issue, and outline any testing performed, and add a pull request template to the repository to ensure future PRs include comprehensive context and rationale.
✅ Passed Checks (2 passed)
Check Name Status Explanation
Title Check ✅ Passed The title succinctly highlights the primary change—adjusting label spacing in the RadioGroupItemField for improved accessibility—and directly reflects the core fix implemented in this PR, making it clear and specific for reviewers scanning the history.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.

Poem

I nudged a label, light and sly,
A hop of padding, tidy and spry.
Nothing moved in logic's den—
Just cleaner lines for eyes and men.
Thump-thump! sings the styling hen 🐇✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title succinctly and accurately summarizes the main change — adjusting spacing in RadioGroupItemField's label to improve accessibility — and matches the changeset which shifts spacing from the wrapper to the label to fix the clickable-gap issue.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/radio-group-spacing

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • 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 930a4bd and acce5f9.

📒 Files selected for processing (1)
  • packages/components/package.json (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • packages/components/package.json
⏰ 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). (1)
  • GitHub Check: test

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

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Sep 8, 2025

📝 Storybook Preview: View Storybook

This preview will be updated automatically when you push new changes to this PR.

Note: The preview will be available after the workflow completes and the PR is approved for deployment.

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 (2)
packages/components/src/ui/radio-group-item-field.tsx (2)

36-39: Enable label’s peer-disabled styles by adding peer to the item.

Without peer on the radio item, the label’s peer-disabled variants never activate.

Apply:

-        className={cn(
-          'h-4 w-4 rounded-full border border-primary text-primary ring-offset-background focus:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50',
+        className={cn(
+          'peer h-4 w-4 rounded-full border border-primary text-primary ring-offset-background focus:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50',
           className,
         )}

64-65: Export the props type to satisfy package guidelines.

Matches “Always export both the component and props type.”

 export { RadioGroupItemField };
+export type { RadioGroupItemFieldProps };
🧹 Nitpick comments (2)
packages/components/src/ui/radio-group-item-field.tsx (2)

50-51: Minor UX: make the label clearly interactive (and RTL-friendly if applicable).

Add cursor-pointer and select-none; optionally swap pl-2 for directional variants if you support RTL.

-            'text-sm pl-2 font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70',
+            'text-sm pl-2 cursor-pointer select-none font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70',

If RTL is supported, consider:

-            'text-sm pl-2 ...
+            'text-sm ltr:pl-2 rtl:pr-2 ...

2-2: Ensure label association even when id isn’t provided (fallback to useId).

Prevents accidental unlabeled items when consumers omit id.

-import type * as React from 'react';
+import type * as React from 'react';
+import { useId } from 'react';
@@
-const RadioGroupItemField = ({
-  label,
-  labelClassName,
-  wrapperClassName,
-  components,
-  className,
-  children,
-  ...props
-}: RadioGroupItemFieldProps) => {
+const RadioGroupItemField = ({
+  label,
+  labelClassName,
+  wrapperClassName,
+  components,
+  className,
+  children,
+  ...props
+}: RadioGroupItemFieldProps) => {
+  const generatedId = useId();
+  const { id: idProp, ...rest } = props as { id?: string };
+  const id = idProp ?? generatedId;
@@
-        {...props}
+        id={id}
+        {...rest}
@@
-          htmlFor={props.id}
+          htmlFor={id}

Also applies to: 19-27, 40-41, 48-49

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • 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 0abcba2 and 930a4bd.

📒 Files selected for processing (1)
  • packages/components/src/ui/radio-group-item-field.tsx (2 hunks)
🧰 Additional context used
📓 Path-based instructions (10)
packages/components/src/ui/**/*.tsx

📄 CodeRabbit inference engine (.cursor/rules/form-component-patterns.mdc)

packages/components/src/ui/**/*.tsx: Build on @radix-ui components as the foundation for base UI components
Follow the component composition pattern for UI components that accept form integration

Files:

  • packages/components/src/ui/radio-group-item-field.tsx
packages/components/src/ui/*.{tsx,ts}

📄 CodeRabbit inference engine (.cursor/rules/form-component-patterns.mdc)

Base UI components should be named as ComponentName in ui/ directory

Files:

  • packages/components/src/ui/radio-group-item-field.tsx
**/*.{tsx,ts}

📄 CodeRabbit inference engine (.cursor/rules/form-component-patterns.mdc)

**/*.{tsx,ts}: Props interfaces should be named as ComponentNameProps
Form schemas should be named formSchema or componentNameSchema

Files:

  • packages/components/src/ui/radio-group-item-field.tsx
packages/components/src/{remix-hook-form,ui}/*.{tsx,ts}

📄 CodeRabbit inference engine (.cursor/rules/form-component-patterns.mdc)

Always export both the component and its props type

Files:

  • packages/components/src/ui/radio-group-item-field.tsx
{apps,packages}/**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/monorepo-organization.mdc)

{apps,packages}/**/*.{ts,tsx}: Use package name imports for published packages (e.g., import { TextField } from '@lambdacurry/forms/remix-hook-form')
Import from specific entry points (e.g., import { TextField } from '@lambdacurry/forms/remix-hook-form/text-field')
Do not use relative imports across packages (e.g., avoid import { TextField } from '../../packages/components/src/remix-hook-form/text-field')
Order imports: 1) external libraries, 2) internal package imports, 3) cross-package imports, 4) type-only imports (grouped separately)

Files:

  • packages/components/src/ui/radio-group-item-field.tsx
{apps,packages}/**/src/**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/monorepo-organization.mdc)

{apps,packages}/**/src/**/*.{ts,tsx}: Use relative imports within the same package (e.g., import { FormControl } from './form')
Use relative imports for sibling directories (e.g., import { Button } from '../ui/button')

Files:

  • packages/components/src/ui/radio-group-item-field.tsx
packages/components/src/**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/monorepo-organization.mdc)

packages/components/src/**/*.{ts,tsx}: Always export both component and props type (e.g., export { ComponentName }; export type { ComponentNameProps };)
Use named exports for components for better tree-shaking (e.g., export const ComponentName = ...; avoid default exports)
Avoid default exports for components
Use tree-shaking friendly exports

Files:

  • packages/components/src/ui/radio-group-item-field.tsx
{apps,packages}/**/src/**/*.{tsx,ts}

📄 CodeRabbit inference engine (.cursor/rules/monorepo-organization.mdc)

{apps,packages}/**/src/**/*.{tsx,ts}: Use kebab-case for component file names (e.g., text-field.tsx, data-table.tsx)
Match component name in PascalCase to the exported component from the file (e.g., text-field.tsx exports TextField)

Files:

  • packages/components/src/ui/radio-group-item-field.tsx
packages/components/src/ui/**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/monorepo-organization.mdc)

Don't import from remix-hook-form package in ui components

Files:

  • packages/components/src/ui/radio-group-item-field.tsx
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/monorepo-organization.mdc)

Avoid circular dependencies

Files:

  • packages/components/src/ui/radio-group-item-field.tsx
🧬 Code graph analysis (1)
packages/components/src/ui/radio-group-item-field.tsx (1)
packages/components/src/ui/utils/index.ts (1)
  • cn (4-6)
⏰ 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). (1)
  • GitHub Check: test
🔇 Additional comments (1)
packages/components/src/ui/radio-group-item-field.tsx (1)

34-34: A11y: Good fix—removing wrapper spacing eliminates the click dead zone.

Shifting spacing responsibility to the label is the right approach for a larger hit target.

@jaruesink
Copy link
Copy Markdown
Contributor

jaruesink commented Sep 18, 2025

@codegen-sh go into the library and use npm to bump the patch version with a summary message, don't publish just bump the version, and push up the change.

Understood! I'll bump the patch version and push the update 🚀

💻 View my work🛑 Stop

- Fix: adjust spacing in RadioGroupItemField label for better a11y
- Patch version bump for accessibility improvements

Co-authored-by: lcmohsen <mohsen@lambdacurry.dev>
@codegen-sh
Copy link
Copy Markdown
Contributor

codegen-sh Bot commented Sep 18, 2025

Version bump completed successfully!

I've bumped the @lambdacurry/forms library from version 0.19.5 to 0.19.6 with a summary message about the RadioGroup accessibility fix.

What was done:

  • 📦 Used npm to bump the patch version in packages/components/package.json
  • 📝 Created a descriptive commit message referencing the accessibility improvement
  • 🌿 Created a new branch: codegen-bot/bump-patch-version-0196
  • 🚀 Pushed the changes to the remote repository

Next steps:

  • The version is now bumped and ready
  • You can create a PR from the branch if needed: Create PR
  • The library is ready for publishing when you're ready (though you mentioned not to publish yet)

The version bump is now live on the remote branch! 🎉

💻 View my work🛑 Stop • React 👍 or 👎

@jaruesink jaruesink merged commit 875bc53 into main Sep 18, 2025
5 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.

2 participants