Commit 74713fe6 by Michael Roytman

fix(asinput): Remove control of state.value from asInput

asInput component was overriding state.value that was set by the parent component. This allows parent to call setState on input components.
parent 4f253ff7
...@@ -41,7 +41,7 @@ describe('asInput()', () => { ...@@ -41,7 +41,7 @@ describe('asInput()', () => {
const wrapper = mount(<InputTestComponent {...props} />); const wrapper = mount(<InputTestComponent {...props} />);
expect(wrapper.find('label').text()).toEqual(props.label); expect(wrapper.find('label').text()).toEqual(props.label);
expect(wrapper.find('#description-asInput1').text()).toEqual(props.description); expect(wrapper.find('#description-asInput1').text()).toEqual(props.description);
expect(wrapper.state('value')).toEqual(props.value); expect(wrapper.prop('value')).toEqual(props.value);
}); });
it('creates generic prop id', () => { it('creates generic prop id', () => {
...@@ -149,7 +149,7 @@ describe('asInput()', () => { ...@@ -149,7 +149,7 @@ describe('asInput()', () => {
const err = wrapper.find('.form-control-feedback'); const err = wrapper.find('.form-control-feedback');
expect(err.exists()).toEqual(true); expect(err.exists()).toEqual(true);
expect(err.text()).toEqual(validationResult.validationMessage); expect(err.text()).toEqual(validationResult.validationMessage);
// expect(err.hasClass('invalid-feedback')).toEqual(true); expect(err.hasClass('invalid-feedback')).toEqual(true);
const dangerIcon = wrapper.find('.fa-exclamation-circle'); const dangerIcon = wrapper.find('.fa-exclamation-circle');
expect(dangerIcon.exists()).toEqual(true); expect(dangerIcon.exists()).toEqual(true);
......
...@@ -38,7 +38,6 @@ const asInput = (WrappedComponent, labelFirst = true) => { ...@@ -38,7 +38,6 @@ const asInput = (WrappedComponent, labelFirst = true) => {
const id = this.props.id ? this.props.id : newId('asInput'); const id = this.props.id ? this.props.id : newId('asInput');
this.state = { this.state = {
id, id,
value: this.props.value,
isValid: true, isValid: true,
describedBy: [], describedBy: [],
errorId: `error-${id}`, errorId: `error-${id}`,
...@@ -97,7 +96,6 @@ const asInput = (WrappedComponent, labelFirst = true) => { ...@@ -97,7 +96,6 @@ const asInput = (WrappedComponent, labelFirst = true) => {
} }
handleChange(event) { handleChange(event) {
this.setState({ value: event.target.value });
this.props.onChange( this.props.onChange(
event.target.type === 'checkbox' ? event.target.checked : event.target.value, event.target.type === 'checkbox' ? event.target.checked : event.target.value,
this.props.name, this.props.name,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment