diff --git a/src/Select.js b/src/Select.js index f96496dca2..79d3903628 100644 --- a/src/Select.js +++ b/src/Select.js @@ -138,6 +138,14 @@ const Select = React.createClass({ } }, + componentWillReceiveProps(nextProps) { + if (this.props.value !== nextProps.value && nextProps.required) { + this.setState({ + required: this.handleRequired(nextProps.value, nextProps.multi), + }); + } + }, + componentWillUpdate (nextProps, nextState) { if (nextState.isOpen !== this.state.isOpen) { const handler = nextState.isOpen ? nextProps.onOpen : nextProps.onClose; diff --git a/test/Select-test.js b/test/Select-test.js index 83b4855575..002db59922 100644 --- a/test/Select-test.js +++ b/test/Select-test.js @@ -2816,6 +2816,18 @@ describe('Select', () => { expect(instance.state.required, 'to be true'); }); + it('input should not have required attribute after updating the component with a value', () => { + wrapper = createControlWithWrapper({ + options: defaultOptions, + value: '', + required: true + }); + + expect(instance.state.required, 'to be true'); + wrapper.setPropsForChild({ value: 'one' }); + expect(instance.state.required, 'to be false'); + }); + }); describe('required with multi=true', () => {