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

[RadioButton] Bug custom wrapper in RadioButtonGroup #4568

Closed
peterbartos opened this issue Jun 25, 2016 · 2 comments
Closed

[RadioButton] Bug custom wrapper in RadioButtonGroup #4568

peterbartos opened this issue Jun 25, 2016 · 2 comments
Labels
component: ButtonGroup The React component. component: radio This is the name of the generic UI component, not the React module!

Comments

@peterbartos
Copy link
Contributor

Cannot use a customized-wrapper-RadioButton inside RadioButtonGroup, because it gets replaced with standard RadioButton component during render.

RadioButtonGroup render should reuse the same RadioButton component instead.

@mpontikes mpontikes mentioned this issue Aug 5, 2016
13 tasks
@egonvb
Copy link

egonvb commented Apr 26, 2017

I ran into the same problem, I've created a RadioButton which is wrapped in a Paper component. However due to the rendering method used in the RadioButtonGroup, the component got replaced. I replaced the rendering method with the following, this way the wrapping still works.

`render() {

const {prepareStyles} = this.context.muiTheme;
const options = React.Children.map(this.props.children, (option) => {

  const {
    name, // eslint-disable-line no-unused-vars
    value, // eslint-disable-line no-unused-vars
    label, // eslint-disable-line no-unused-vars
    onCheck, // eslint-disable-line no-unused-vars
    ...other
  } = option.props;

  return React.cloneElement( option,{
      ...other,
      ref           : option.props.value,
      name          : this.props.name,
      key           : option.props.value,
      value         : option.props.value,
      label         : option.props.label,
      labelPosition : this.props.labelPosition,
      onCheck       : this.handleChange,
      checked       : option.props.value === this.state.selected
  });
}, this);`

the wrapped component looked like this

class Answer extends Component{ render(){ return <Paper> <RadioButton {...this.props} </Paper> } }

Note: wrapper has to be a class, a stateless function cannot be used because ref is used by the radiobuttongroup.

@oliviertassinari oliviertassinari changed the title Bug custom wrapper RadioButton in RadioButtonGroup [RadioButton] Bug custom wrapper in RadioButtonGroup May 16, 2017
@oliviertassinari
Copy link
Member

We have been porting the component on the v1-beta branch. We reimplemented it from the ground-up. While we haven't tested it, I think that the issue is most likely fixed on that branch. Hence, I'm closing it.
Still, we will accept PR fixes until v1-beta takes over the master branch.

@oliviertassinari oliviertassinari added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Dec 21, 2022
@zannager zannager added component: radio This is the name of the generic UI component, not the React module! component: ButtonGroup The React component. and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Jan 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: ButtonGroup The React component. component: radio This is the name of the generic UI component, not the React module!
Projects
None yet
Development

No branches or pull requests

4 participants