diff --git a/CHANGELOG.md b/CHANGELOG.md index 089f1fa80..a6b7b84ff 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +* 0.1.1 + ** HOTFIX ** + + - [#913](https://github.com/City-of-Helsinki/varaamo/pull/913) Fix issue staff comment section is not working. Reason: React-bootstrap ref prop which is deprecated and replace with inputProps * 0.1.0 ** MAJOR CHANGES ** @@ -21,7 +25,7 @@ - #875: Expand advanced search panel when filters are applied. - - #876: Free-of-charge filter for resources. + - #876: Free-of-charge filter for resources. - #878: Remove the link for old website from the footer. diff --git a/app/shared/comment-form/CommentForm.js b/app/shared/comment-form/CommentForm.js index f2c84e1ec..885682dd9 100644 --- a/app/shared/comment-form/CommentForm.js +++ b/app/shared/comment-form/CommentForm.js @@ -17,7 +17,7 @@ class CommentForm extends Component { handleSave(event) { event.preventDefault(); - const comments = this.commentsInput.current.value; + const comments = this.commentsInput.value; this.props.onSave(comments); } @@ -33,8 +33,9 @@ class CommentForm extends Component { this.commentsInput = ref} placeholder={t('CommentForm.placeholder')} - ref={this.commentsInput} rows={5} /> diff --git a/app/shared/comment-form/CommentForm.spec.js b/app/shared/comment-form/CommentForm.spec.js index 9d24849c5..3eac7a174 100644 --- a/app/shared/comment-form/CommentForm.spec.js +++ b/app/shared/comment-form/CommentForm.spec.js @@ -27,11 +27,18 @@ describe('shared/comment-form/CommentForm', () => { describe('comments textarea', () => { test('renders a FormControl with correct props', () => { - const formControl = getWrapper().find(FormControl); + const wrapper = getWrapper(); + const formControl = wrapper.find(FormControl); + const mockRef = { value: 'foo' }; + + formControl.prop('inputRef')(mockRef); + // change input expect(formControl.length).toBe(1); expect(formControl.prop('componentClass')).toBe('textarea'); expect(formControl.prop('defaultValue')).toBe(defaultProps.defaultValue); + expect(typeof formControl.prop('inputRef')).toBe('function'); + expect(wrapper.instance().commentsInput).toEqual(mockRef); }); }); @@ -75,7 +82,7 @@ describe('shared/comment-form/CommentForm', () => { beforeAll(() => { const instance = getWrapper().instance(); // override ref value to mock - instance.commentsInput.current = { value: comments }; + instance.commentsInput = { value: comments }; defaultProps.onSave.reset(); instance.handleSave(mockEvent); diff --git a/app/shared/modals/reservation-info/ReservationInfoModal.js b/app/shared/modals/reservation-info/ReservationInfoModal.js index 40f244492..c3e6d6c14 100644 --- a/app/shared/modals/reservation-info/ReservationInfoModal.js +++ b/app/shared/modals/reservation-info/ReservationInfoModal.js @@ -29,7 +29,7 @@ class ReservationInfoModal extends Component { } handleSaveCommentsClick() { - const comments = this.commentsInput.current.value; + const comments = this.commentsInput.value; this.props.onSaveCommentsClick(comments); } @@ -98,8 +98,9 @@ class ReservationInfoModal extends Component { componentClass="textarea" defaultValue={reservation.comments} disabled={disabled} + // eslint-disable-next-line no-return-assign + inputRef={ref => this.commentsInput = ref} placeholder={t('common.commentsPlaceholder')} - ref={this.commentsInput} rows={5} /> diff --git a/app/shared/modals/reservation-info/ReservationInfoModal.spec.js b/app/shared/modals/reservation-info/ReservationInfoModal.spec.js index 28e4e4c42..e125762c4 100644 --- a/app/shared/modals/reservation-info/ReservationInfoModal.spec.js +++ b/app/shared/modals/reservation-info/ReservationInfoModal.spec.js @@ -121,10 +121,18 @@ describe('shared/modals/reservation-info/ReservationInfoModal', () => { }); test('renders textarea FormControl for comments with correct props', () => { - const formControl = getCommentsForm(props).find(FormControl); + const wrapper = getWrapper(props); + const formControl = wrapper.find('.comments-form').find(FormControl); + const mockRef = { value: 'foo' }; + + formControl.prop('inputRef')(mockRef); + // change input value + expect(formControl).toHaveLength(1); expect(formControl.prop('componentClass')).toBe('textarea'); expect(formControl.prop('defaultValue')).toBe(reservation.comments); + expect(typeof formControl.prop('inputRef')).toBe('function'); + expect(wrapper.instance().commentsInput).toEqual(mockRef); }); test('renders a save button with correct onClick prop', () => { @@ -363,7 +371,7 @@ describe('shared/modals/reservation-info/ReservationInfoModal', () => { beforeAll(() => { const instance = getWrapper({ onSaveCommentsClick }).instance(); // override ref value to mock - instance.commentsInput.current = { value: comments }; + instance.commentsInput = { value: comments }; instance.handleSaveCommentsClick(); }); diff --git a/package.json b/package.json index 16f4fcb15..6bf20b434 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "varaamo", - "version": "0.1.0", + "version": "0.1.1", "repository": { "type": "git", "url": "https://github.com/City-of-Helsinki/varaamo"