diff --git a/web/ASC.Web.Components/src/components/checkbox/index.js b/web/ASC.Web.Components/src/components/checkbox/index.js index d884de9acd..8336876ef4 100644 --- a/web/ASC.Web.Components/src/components/checkbox/index.js +++ b/web/ASC.Web.Components/src/components/checkbox/index.js @@ -105,6 +105,16 @@ const Text = styled.span` class Checkbox extends React.Component { + constructor(props) { + super(props); + + this.ref = React.createRef(); + + this.state = { + checked: props.isChecked + }; + } + componentDidMount() { this.ref.current.indeterminate = this.props.isIndeterminate; } @@ -113,18 +123,21 @@ class Checkbox extends React.Component { if(this.props.isIndeterminate !== prevProps.isIndeterminate) { this.ref.current.indeterminate = this.props.isIndeterminate; } + if(this.props.isChecked !== prevProps.isChecked) { + this.setState({checked: this.props.isChecked}); + } } - - ref = React.createRef(); - render() { const cbxClassName = 'checkbox' + - (this.props.isIndeterminate ? ' indeterminate' : this.props.isChecked ? ' checked' : '') + + (this.props.isIndeterminate ? ' indeterminate' : this.state.checked ? ' checked' : '') + (this.props.isDisabled ? ' disabled' : ''); return (