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()', () => {
const wrapper = mount(<InputTestComponent {...props} />);
expect(wrapper.find('label').text()).toEqual(props.label);
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', () => {
......@@ -149,7 +149,7 @@ describe('asInput()', () => {
const err = wrapper.find('.form-control-feedback');
expect(err.exists()).toEqual(true);
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');
expect(dangerIcon.exists()).toEqual(true);
......
......@@ -38,7 +38,6 @@ const asInput = (WrappedComponent, labelFirst = true) => {
const id = this.props.id ? this.props.id : newId('asInput');
this.state = {
id,
value: this.props.value,
isValid: true,
describedBy: [],
errorId: `error-${id}`,
......@@ -97,7 +96,6 @@ const asInput = (WrappedComponent, labelFirst = true) => {
}
handleChange(event) {
this.setState({ value: event.target.value });
this.props.onChange(
event.target.type === 'checkbox' ? event.target.checked : event.target.value,
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