From 7d507937dd74b76cff3d7aa9aa9aedec8abe8de9 Mon Sep 17 00:00:00 2001 From: Bogdan Cochior <bogdan.cochior@thinslices.com> Date: Fri, 18 May 2018 10:44:21 +0300 Subject: [PATCH] fix(reports): fix show more/less by adding id --- .../src/components/ReviewReportCard.js | 4 ++-- packages/component-manuscript/src/components/ShowMore.js | 7 ++++--- packages/component-manuscript/src/components/utils.js | 6 +++--- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/packages/component-manuscript/src/components/ReviewReportCard.js b/packages/component-manuscript/src/components/ReviewReportCard.js index e306ed05d..db3501bb3 100644 --- a/packages/component-manuscript/src/components/ReviewReportCard.js +++ b/packages/component-manuscript/src/components/ReviewReportCard.js @@ -50,7 +50,7 @@ const ReviewReportCard = ({ <Label>Report Text</Label> </Row> <Row> - <ShowMore content={publicComment.content} /> + <ShowMore content={publicComment.content} id="public-content" /> </Row> </Fragment> )} @@ -77,7 +77,7 @@ const ReviewReportCard = ({ <Label>Confidential Note</Label> </Row> <Row> - <ShowMore content={privateComment.content} /> + <ShowMore content={privateComment.content} id="private-content" /> </Row> </Fragment> )} diff --git a/packages/component-manuscript/src/components/ShowMore.js b/packages/component-manuscript/src/components/ShowMore.js index df021730b..937fda9d9 100644 --- a/packages/component-manuscript/src/components/ShowMore.js +++ b/packages/component-manuscript/src/components/ShowMore.js @@ -2,14 +2,14 @@ import React, { Fragment } from 'react' import { Icon } from '@pubsweet/ui' import styled from 'styled-components' -const ShowMore = ({ content = '', words = 50 }) => { +const ShowMore = ({ content = '', words = 50, id = 'read-more-target' }) => { const contentSize = content.split(' ').length return ( <Root> {contentSize > words && ( <Fragment> - <Input id="read-more-target" role="button" type="checkbox" /> - <Control htmlFor="read-more-target"> + <Input id={id} role="button" type="checkbox" /> + <Control htmlFor={id}> <div> <Icon primary>chevron-down</Icon> Show All </div> @@ -73,6 +73,7 @@ const Input = styled.input` const Control = styled.label` cursor: pointer; + width: fit-content; div { text-decoration: underline; text-transform: uppercase; diff --git a/packages/component-manuscript/src/components/utils.js b/packages/component-manuscript/src/components/utils.js index 6ef3a6061..fcc8c9f23 100644 --- a/packages/component-manuscript/src/components/utils.js +++ b/packages/component-manuscript/src/components/utils.js @@ -144,11 +144,11 @@ const onChange = ( dispatch(autosaveRequest()) if (newValues.id) { updateRecommendation(project.id, version.id, newValues) - .then(r => dispatch(autosaveSuccess(r.updatedOn))) + .then(r => dispatch(autosaveSuccess(get(r, 'updatedOn')))) .catch(e => dispatch(autosaveFailure(e))) } else { createRecommendation(project.id, version.id, newValues) - .then(r => dispatch(autosaveSuccess(r.updatedOn))) + .then(r => dispatch(autosaveSuccess(get(r, 'updatedOn')))) .catch(e => dispatch(autosaveFailure(e))) } } @@ -177,7 +177,7 @@ export const onReviewSubmit = ( newValues.submittedOn = Date.now() dispatch(autosaveRequest()) updateRecommendation(project.id, version.id, newValues) - .then(r => dispatch(autosaveSuccess(r.updatedOn))) + .then(r => dispatch(autosaveSuccess(get(r, 'updatedOn')))) .then(hideModal) }, onCancel: hideModal, -- GitLab