Skip to content

Commit

Permalink
Merge pull request #279 from mmrtnz/master
Browse files Browse the repository at this point in the history
Fixed ui bug for switches
  • Loading branch information
hai-cea committed Jan 27, 2015
2 parents 57c7a95 + a3e1b69 commit 7e9f069
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 9 deletions.
6 changes: 2 additions & 4 deletions docs/src/app/components/pages/components/switches.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -344,8 +344,7 @@ var SwitchesPage = React.createClass({
id="toggleId1"
name="toggleName1"
value="toggleValue1"
label="activate thrusters"
onToggle={this._onToggle}/>
label="activate thrusters"/>
</div>
<div className="switches-example-container">
<Toggle
Expand Down Expand Up @@ -380,8 +379,7 @@ var SwitchesPage = React.createClass({

<RadioButtonGroup
name="shipSpeed"
defaultSelected="not_light"
onChange={this._onRadioButtonClick}>
defaultSelected="not_light">
<RadioButton
id="radioButtonId1"
value="light"
Expand Down
2 changes: 1 addition & 1 deletion src/js/checkbox.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ var Checkbox = React.createClass({
},

_onCheck: function(e, isInputChecked) {
if (!this.props.hasOwnProperty('checked')) this.setState({checked: !this.refs.enhancedSwitch.state.checked});
if (!this.props.hasOwnProperty('checked')) this.setState({checked: isInputChecked});
if (this.props.onCheck) this.props.onCheck(e, isInputChecked);
},

Expand Down
3 changes: 1 addition & 2 deletions src/js/enhanced-switch.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ var EnhancedSwitch = React.createClass({
(nextProps.defaultSwitched != this.props.defaultSwitched));
var newState = {};


if (hasCheckedProp) {
newState.switched = nextProps.checked;
} else if (hasCheckedLinkProp) {
Expand Down Expand Up @@ -95,7 +94,7 @@ var EnhancedSwitch = React.createClass({

_handleChange: function(e) {
var isInputChecked = this.refs.checkbox.getDOMNode().checked;

if (!this.props.hasOwnProperty('checked')) this.setState({switched: isInputChecked});
if (this.props.onSwitch) this.props.onSwitch(e, isInputChecked);
},
Expand Down
4 changes: 2 additions & 2 deletions src/js/toggle.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ var Toggle = React.createClass({
ref="enhancedSwitch"
inputType="checkbox"
onSwitch={this._onToggle}
defaultSwitched={this.props.defaultToggled} />
defaultChecked={this.props.defaultToggled} />

{divsInOrder}

Expand All @@ -104,7 +104,7 @@ var Toggle = React.createClass({
},

_onToggle: function(e, isInputChecked) {
if (!this.props.hasOwnProperty('checked')) this.setState({toggled: !this.refs.enhancedSwitch.state.toggled});
if (!this.props.hasOwnProperty('checked')) this.setState({toggled: isInputChecked});
if (this.props.onToggle) this.props.onToggle(e, isInputChecked);
},

Expand Down

0 comments on commit 7e9f069

Please sign in to comment.