Skip to content
This repository has been archived by the owner on Mar 1, 2024. It is now read-only.

<Form.SelectGroupItem> not accepting event handler #219

Closed
c-kirkeby opened this issue Jun 6, 2018 · 4 comments
Closed

<Form.SelectGroupItem> not accepting event handler #219

c-kirkeby opened this issue Jun 6, 2018 · 4 comments

Comments

@c-kirkeby
Copy link

c-kirkeby commented Jun 6, 2018

The <Form.SelectGroupItem> component is not accepting event handlers. e.g.

<Form>
  <Form.Group>
    <Form.SelectGroup>
      <Form.SelectGroupItem label='foo' value='foo' onChange={() => alert('foo')}>
      <Form.SelectGroupItem label='bar' value='bar' onChange={() => alert('bar')}>
    <Form.SelectGroup>
  <Form.Group>
<Form>

Toggling the radio buttons above won't call the onChange function. I was able to get around this by just using plain HTML with the classes from tabler.

@iamzjohn
Copy link
Contributor

iamzjohn commented Jun 6, 2018

Hi @JHeebz I think u are placing wrong the event cuz if the onChange should be placed on the Form.SelectGroup instead of the SelectGroupItem, If u want to archive the effect using SelectGroupItem u can change the event to onClick instead of onChange

The correct way using onClick:

<Form>
  <Form.Group>
    <Form.SelectGroup>
      <Form.SelectGroupItem label='foo' value='foo' onClick={() => alert('foo')}>
      <Form.SelectGroupItem label='bar' value='bar' onClick={() => alert('bar')}>
    <Form.SelectGroup>
  <Form.Group>
<Form>

Correct way using onChange

constructor(){
this.handleChange = this.handleChange.bind(this);
}
handleChange(e){
alert(e.target.value);
}
<Form>
  <Form.Group>
    <Form.SelectGroup  onChange={this.handleChange(e)}>
      <Form.SelectGroupItem label='foo' value='foo'>
      <Form.SelectGroupItem label='bar' value='bar'>
    <Form.SelectGroup>
  <Form.Group>
<Form>

@c-kirkeby
Copy link
Author

c-kirkeby commented Jun 6, 2018

Form.SelectGroup doesn't accept an event handler either. Using just plain HTML elements I can put the event handler on either selectgroup-item or select-group. I'll try to add an example tonight.

@jonthomp jonthomp self-assigned this Jun 15, 2018
@Greg-Hamel
Copy link
Contributor

@jonthomp, I’ll be merging a PR to resolve this soon. I have it ready, just need to fix the flow errors I have caused in some other components which depend on Form Elements

@jonthomp jonthomp removed their assignment Jun 15, 2018
Greg-Hamel added a commit to Greg-Hamel/tabler-react that referenced this issue Jun 18, 2018
@jonthomp
Copy link
Contributor

🎉 This issue has been resolved in version 1.12.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants