Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(16248): RadioButtonGroup supports 'required' prop and attaches it to children RadioButton #16300

Conversation

2nikhiltom
Copy link
Contributor

Closes #16248

RadioButtonGroup supports 'required' prop and attaches it to children RadioButton

New

  • RadioButtonGroup supports 'required' prop and attaches it to children RadioButton
  • RadioButton supports 'required' prop and attaches it to underlying Input
  • Adds new TestCases to verify this functionality

The required attribute has to be specified only on RadioButtonGroup instead of on every child RadioButton


<RadioButtonGroup required name="group" legendText="Storage tier (disk)">
          <RadioButton labelText="Free (1 GB)" value="free" />
          <RadioButton labelText="Standard (10 GB)" value="standard" />
 </RadioButtonGroup>

Changed

  • RadioTile accepts required prop
  • PublicAPI snapshot updated with 'required' boolean attribute
  • The required attribute has to be specified only on RadioButtonGroup instead of on every child RadioButton

Testing / Reviewing

  • (Take pull of this PR and update any one of the storybook example with below code )
  • Verify required attribute is attached to all children RadioButton
export const Test = () => {
  function onSubmit(e) {
    e.preventDefault();
    alert('submitted');
  }

  return (
    <div style={{ padding: '2em' }}>
      <Form onSubmit={onSubmit}>
        <RadioButtonGroup name="radio" required>
          <RadioButton value="1"   labelText="test-label">
            Tile 1
          </RadioButton>
          <RadioButton value="2"  labelText="test-label">
            Tile 2
          </RadioButton>
          <RadioButton value="3"  labelText="test-label">
            Tile 3
          </RadioButton>
        </RadioButtonGroup>
        <Button type="submit">Submit</Button>
      </Form>
    </div>
  );
};

@2nikhiltom 2nikhiltom requested review from a team as code owners May 2, 2024 03:43
Copy link

netlify bot commented May 2, 2024

Deploy Preview for v11-carbon-react ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit b85073b
🔍 Latest deploy log https://app.netlify.com/sites/v11-carbon-react/deploys/66330bca6647ee000830f8c6
😎 Deploy Preview https://deploy-preview-16300--v11-carbon-react.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

netlify bot commented May 2, 2024

Deploy Preview for v11-carbon-react ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 5241ef3
🔍 Latest deploy log https://app.netlify.com/sites/v11-carbon-react/deploys/663b4dd9094ce10008e0cf89
😎 Deploy Preview https://deploy-preview-16300--v11-carbon-react.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link
Contributor

@preetibansalui preetibansalui left a comment

Choose a reason for hiding this comment

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

LGTM

@2nikhiltom 2nikhiltom requested a review from a team as a code owner May 8, 2024 10:03
@2nikhiltom 2nikhiltom requested a review from guidari May 8, 2024 10:03
@2nikhiltom 2nikhiltom added this pull request to the merge queue May 8, 2024
Merged via the queue into carbon-design-system:main with commit c405ed8 May 8, 2024
20 checks passed
@2nikhiltom 2nikhiltom deleted the 16248_radioButton_required_attr_fetch branch May 8, 2024 11:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants