Skip to content

fix(core): checkbox issue with default value and required validation#2377

Merged
jorgemoya merged 1 commit into
canaryfrom
fix-required-checkbox
Jun 6, 2025
Merged

fix(core): checkbox issue with default value and required validation#2377
jorgemoya merged 1 commit into
canaryfrom
fix-required-checkbox

Conversation

@jorgemoya

@jorgemoya jorgemoya commented Jun 5, 2025

Copy link
Copy Markdown
Contributor

What/Why?

  • Fixes an issue with the checkbox not properly triggering the required validation.
  • Fixes an issue with the checkbox not setting the default value from the API.
  • Fixes an issue with the field value being incorrectly set as undefined

Testing

Locally.

Migration

Update the props to set a checked value and pasa an empty string when checked box is unselected.

case 'checkbox':
    return (
    <Checkbox
        checked={controls.value === 'true'}
        errors={formField.errors}
        key={formField.id}
        label={field.label}
        name={formField.name}
        onBlur={controls.blur}
        onCheckedChange={(value) => handleChange(value ? 'true' : '')}
        onFocus={controls.focus}
        required={formField.required}
        value={controls.value ?? ''}
    />
    );

@jorgemoya
jorgemoya requested a review from a team June 5, 2025 21:48
@changeset-bot

changeset-bot Bot commented Jun 5, 2025

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 3e2a008

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@bigcommerce/catalyst-core Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel

vercel Bot commented Jun 5, 2025

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
catalyst 🔄 Building (Inspect) Visit Preview 💬 Add feedback Jun 5, 2025 9:55pm
catalyst-canary ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 5, 2025 9:55pm
2 Skipped Deployments
Name Status Preview Comments Updated (UTC)
catalyst-au ⬜️ Ignored (Inspect) Visit Preview Jun 5, 2025 9:55pm
catalyst-uk ⬜️ Ignored (Inspect) Visit Preview Jun 5, 2025 9:55pm

@matthewvolk matthewvolk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Tested locally, LGTM 👍

@jorgemoya
jorgemoya added this pull request to the merge queue Jun 6, 2025
Merged via the queue into canary with commit 2de3c51 Jun 6, 2025
9 checks passed
@jorgemoya
jorgemoya deleted the fix-required-checkbox branch June 6, 2025 15:06
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