Document that ToggleButtonGroup doesn't work when Bootstrap JS is present
This is my code:
<ToggleButtonGroup
name="eventType"
type="radio"
value={this.state.eventType}
onChange={(eventType) => this.setState({eventType})}>
<ToggleButton bsStyle="default-washed"
value="business">
Business
</ToggleButton>
<ToggleButton bsStyle="default-washed"
value="leisure">Leisure
</ToggleButton>
</ToggleButtonGroup>
The state is not being changed. However the selected value in the component itself changes as the active button changes. I've tested other places as well. This happens after I've updated from 0.31.0 to 0.31.2
Same as https://github.com/react-bootstrap/react-bootstrap/issues/2734. We can't do anything without a runnable repro.
i'm still fairly sure this is because of a bug in radio/checkboxes in React 15.6.1
Still having this problem. @taion repro was posted in issue #2734 https://github.com/react-bootstrap/react-bootstrap/issues/2734#issuecomment-318102096
As you can see from the following 2 posts in that thread, that was not actually repro.
@taion sorry, it looks like the problem is not in your library.
Reproduced it and everything works fine https://codepen.io/alexschilpp/pen/PJwdxX
@alexschilpp It seems the issue occurs when bootstrap js lib included https://codepen.io/kamote/pen/gGvadB
@kamote I am having the same issue, my Checkbox is not being toggled while my non bootstrap checkbox works fine. I have regular bootstrap running for non react pages, besides for react-bootstrap. Any workaround?
@kamote Probably, because react-BS adds a data-toggle="buttons" attribute, and BS attaches its handler to the elements that have those.
@jquense Should we drop the data-toggle prop?
It sounds like the resolution here is that users must not include the Bootstrap JS when using toggle groups here.
This would be a great addition to the docs, if anybody cares to PR.
I am still having this problem with the BootstrapJS removed. Is there another fix?
Same here
There's also a workaround of setting an onClick handler on each individual ToggleButton. This worked for me (I'm working on an app where removing the bootstrap JS is not an option). This would be good to document as well.
@mreishus this workaround makes my day. As you, I can't remove bootstrap JS. If this bug will be still there in the 1.0, it would be nice to document it (official doc, release notes, ...).
@taion I'm happy to create a PR to update this documentation I can't see ToggleButtonGroup in the documentation anywhere. Am I missing something?
@jquense did this get dropped from the new docs?
It's definitely possible
So I was looking for this component, didn't see it in the docs. I typed import { Toggle... in vs code and saw it does exist. Then I started to lose my mind wondering why my onChange was not getting called. I read the source code and didn't see any reason. Moral of the story, never forget that Github issues >= documentation.
I looked a little bit into the issue as I also have the need to have bootstrap.js and react-bootstrap in my application.
These are the problematic lines in (at least) boostrap-3.3.7: https://github.com/twbs/bootstrap/blob/v3.3.7/js/button.js#L66
Here checked is being change and with that, react-bootstrap does not see any change.
And in combination, this line is affecting the outcome as well: https://github.com/twbs/bootstrap/blob/v3.3.7/js/button.js#L115
If the event is not propagated, react-bootstrap does not see it.
Furthermore, I could not make onChange work on ToggleButton itself. Need to investigate this a bit further.
Edit: ToggleButton has exactly the same issues, as both lines in bootstrap lead to the same behaviour. So actually there is not way in my setup to use bootrstrap.js and react-bootstrap together (without hacking either one)
this was fixed in #2956