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

Commit

Permalink
Merge pull request #379 from 3DStreet/fix/issue-374/boolean-widget
Browse files Browse the repository at this point in the history
fix: boolean widget
  • Loading branch information
kfarr committed Feb 4, 2024
2 parents a2d6d12 + 48d8fee commit 787a78e
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions src/components/widgets/BooleanWidget.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,33 +26,31 @@ export default class BooleanWidget extends React.Component {
}
}

onChange = (e) => {
var value = e.target.checked;
this.setState({ value: value });
onChange = () => {
const value = !this.state.value;

this.setState({ value });
if (this.props.onChange) {
this.props.onChange(this.props.name, value);
}
};

render() {
var id = this.props.componentname + '.' + this.props.name;
const id = this.props.componentname + '.' + this.props.name;

const checkboxClasses = classNames({
checkboxAnim: true,
checked: this.state.value
});

return (
<div
className={checkboxClasses}
onClick={() => this.setState({ value: !this.state.value })}
>
<div className={checkboxClasses} onClick={this.onChange}>
<input
id={id}
type="checkbox"
checked={this.state.value}
value={this.state.value}
onChange={this.onChange}
onChange={() => null}
/>
<label htmlFor={id} onClick={(e) => e.stopPropagation()} />
</div>
Expand Down

0 comments on commit 787a78e

Please sign in to comment.