Skip to content

feat: add description in boolean field#75

Merged
joshunrau merged 1 commit intoDouglasNeuroInformatics:mainfrom
weijietan-fc:main
Oct 27, 2025
Merged

feat: add description in boolean field#75
joshunrau merged 1 commit intoDouglasNeuroInformatics:mainfrom
weijietan-fc:main

Conversation

@weijietan-fc
Copy link
Contributor

@weijietan-fc weijietan-fc commented Oct 9, 2025

Summary by CodeRabbit

  • New Features
    • Boolean form fields now support an optional description displayed beneath the label, available for both checkbox and radio variants.
    • Provides contextual helper text to guide users when making selections, improving clarity for complex toggles.
    • Backward-compatible: existing forms continue to work without changes if no description is provided.
    • No impact on interaction behavior, validation messaging, or disabled/read-only states—this is a presentation enhancement only.

@coderabbitai
Copy link

coderabbitai bot commented Oct 9, 2025

Walkthrough

Adds an optional description prop to BooleanFieldCheckbox and BooleanFieldRadio, rendering it via FieldGroup.Description within the existing FieldGroup layout. Public component signatures are updated to include description. No changes to value handling, error logic, or other behavior.

Changes

Cohort / File(s) Summary
BooleanField description prop
src/components/Form/BooleanField/BooleanFieldCheckbox.tsx, src/components/Form/BooleanField/BooleanFieldRadio.tsx
Add optional description prop to public component signatures; render FieldGroup.Description inside FieldGroup.Row. No changes to value parsing, error handling, or other logic.

Sequence Diagram(s)

sequenceDiagram
  participant U as User
  participant C as BooleanFieldCheckbox/Radio
  participant FG as FieldGroup
  participant D as FieldGroup.Description

  U->>C: Render with { label, value, description? }
  C->>FG: Render FieldGroup (label, error, readOnly, disabled)
  C->>D: If description provided, render description text
  U->>C: Interact (check/select)
  C->>C: Maintain existing value handling (unchanged)
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

Two toggles gain a whisper line,
A hint beneath the checkbox sign.
Radios nod, descriptions show,
Quiet text to help you know.
No logic stirred, just clearer light—
Small words to make the choice feel right.

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 summarizes the addition of a description prop to boolean field components and clearly reflects the primary change without unnecessary detail, following a concise conventional commit style.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 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

@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

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 81d2841 and 688c9f8.

📒 Files selected for processing (2)
  • src/components/Form/BooleanField/BooleanFieldCheckbox.tsx (2 hunks)
  • src/components/Form/BooleanField/BooleanFieldRadio.tsx (3 hunks)
🧰 Additional context used
🧬 Code graph analysis (2)
src/components/Form/BooleanField/BooleanFieldCheckbox.tsx (1)
src/components/Form/FieldGroup/FieldGroup.tsx (1)
  • FieldGroup (6-10)
src/components/Form/BooleanField/BooleanFieldRadio.tsx (2)
src/components/Form/FieldGroup/FieldGroup.tsx (1)
  • FieldGroup (6-10)
src/components/Label/Label.tsx (1)
  • Label (13-18)
🔇 Additional comments (3)
src/components/Form/BooleanField/BooleanFieldRadio.tsx (2)

59-59: LGTM! Correct placement for description.

The description is rendered before the option rows, providing context before the choices. This is the appropriate placement for radio groups.


26-36: Ensure description exists on the radio variant type
Confirm that the radio variant of BooleanFormField in @douglasneuroinformatics/libui-form-types defines an optional description field.

src/components/Form/BooleanField/BooleanFieldCheckbox.tsx (1)

15-24: Verify description prop on BooleanFormField checkbox variant
Component destructures description, but confirm the external BooleanFormField type (variant: 'checkbox') defines this optional field.

}}
/>
<Label htmlFor={name}>{label}</Label>
<FieldGroup.Description description={description} />
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Inconsistent placement compared to BooleanFieldRadio.

In this component, FieldGroup.Description is rendered inside FieldGroup.Row after the Label, but in BooleanFieldRadio.tsx (line 59), it's placed before the FieldGroup.Row elements. This creates inconsistent visual layouts between the two variants.

Apply this diff to align with the radio variant's placement (before FieldGroup.Row):

     <FieldGroup name={name}>
+      <FieldGroup.Description description={description} />
       <FieldGroup.Row>
         <Checkbox
           checked={Boolean(value)}
           disabled={disabled || readOnly}
           id={name}
           name={name}
           onCheckedChange={(value) => {
             if (typeof value === 'boolean') {
               setValue(value);
             }
           }}
         />
         <Label htmlFor={name}>{label}</Label>
-        <FieldGroup.Description description={description} />
       </FieldGroup.Row>
📝 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
<FieldGroup.Description description={description} />
<FieldGroup name={name}>
<FieldGroup.Description description={description} />
<FieldGroup.Row>
<Checkbox
checked={Boolean(value)}
disabled={disabled || readOnly}
id={name}
name={name}
onCheckedChange={(value) => {
if (typeof value === 'boolean') {
setValue(value);
}
}}
/>
<Label htmlFor={name}>{label}</Label>
- <FieldGroup.Description description={description} />
</FieldGroup.Row>
🤖 Prompt for AI Agents
In src/components/Form/BooleanField/BooleanFieldCheckbox.tsx around line 40, the
FieldGroup.Description is currently rendered inside FieldGroup.Row after the
Label which is inconsistent with BooleanFieldRadio; move the
FieldGroup.Description out of/above the FieldGroup.Row so it is rendered before
the Row (matching the radio variant), preserving the same description prop and
any surrounding conditional rendering or styling so layout and semantics stay
identical to BooleanFieldRadio.

<Label
aria-disabled={disabled || readOnly}
className="font-normal text-muted-foreground"
className="text-muted-foreground font-normal"
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Undocumented className changes.

The PR title and AI summary indicate only adding description functionality, but these lines introduce "text-muted-foreground font-normal" classNames that weren't mentioned. Confirm these styling changes are intentional.

Also applies to: 74-74

🤖 Prompt for AI Agents
In src/components/Form/BooleanField/BooleanFieldRadio.tsx around lines 64 and
74, two className additions ("text-muted-foreground font-normal") were
introduced without documentation or mention in the PR; either confirm these
styling changes are intentional and document them in the component/PR
description, or revert them. If the style should be optional, expose a prop
(e.g., descriptionClassName or muted) and apply the new classes conditionally,
and update the component JSDoc/README and PR summary to reflect the styling
change.

@joshunrau joshunrau merged commit 84471a2 into DouglasNeuroInformatics:main Oct 27, 2025
2 checks passed
@github-actions
Copy link

🎉 This PR is included in version 4.9.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants