From a3c1f0daef8f31f129d1275544cdcfba96db44b9 Mon Sep 17 00:00:00 2001 From: Furkan Date: Mon, 31 Oct 2022 22:53:06 +0300 Subject: [PATCH 1/3] fix: ios offline message edit --- src/components/OfflineWithFeedback.js | 7 ++++++- src/pages/home/report/ReportActionItem.js | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/components/OfflineWithFeedback.js b/src/components/OfflineWithFeedback.js index c02441f61ecd..7de34dc0475c 100644 --- a/src/components/OfflineWithFeedback.js +++ b/src/components/OfflineWithFeedback.js @@ -49,11 +49,16 @@ const propTypes = { /** Additional style object for the error row */ errorRowStyles: stylePropTypes, + /** User draft to update message */ + // eslint-disable-next-line react/forbid-prop-types + draftMessage: PropTypes.any, + ...withLocalizePropTypes, }; const defaultProps = { pendingAction: null, + draftMessage: null, errors: null, shouldShowErrorMessages: true, onClose: () => {}, @@ -85,7 +90,7 @@ const OfflineWithFeedback = (props) => { const isOfflinePendingAction = props.network.isOffline && props.pendingAction; const isUpdateOrDeleteError = hasErrors && (props.pendingAction === 'delete' || props.pendingAction === 'update'); const isAddError = hasErrors && props.pendingAction === 'add'; - const needsOpacity = (isOfflinePendingAction && !isUpdateOrDeleteError) || isAddError; + const needsOpacity = (isOfflinePendingAction && !isUpdateOrDeleteError && !props.draftMessage) || isAddError; const needsStrikeThrough = props.network.isOffline && props.pendingAction === 'delete'; const hideChildren = !props.network.isOffline && props.pendingAction === 'delete' && !hasErrors; let children = props.children; diff --git a/src/pages/home/report/ReportActionItem.js b/src/pages/home/report/ReportActionItem.js index 6c6a852699af..0157d126e334 100644 --- a/src/pages/home/report/ReportActionItem.js +++ b/src/pages/home/report/ReportActionItem.js @@ -198,6 +198,7 @@ class ReportActionItem extends Component { pendingAction={this.props.action.pendingAction} errors={this.props.action.errors} errorRowStyles={[styles.ml10, styles.mr2]} + draftMessage={this.props.draftMessage} > {!this.props.displayAsGroup ? ( From 5e7a043be54f9b382c762cb99e7bb274a49c13f1 Mon Sep 17 00:00:00 2001 From: Furkan Date: Thu, 3 Nov 2022 09:44:50 +0300 Subject: [PATCH 2/3] fix: remove forbid-prop-types --- src/components/OfflineWithFeedback.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/components/OfflineWithFeedback.js b/src/components/OfflineWithFeedback.js index 7de34dc0475c..006c8545e699 100644 --- a/src/components/OfflineWithFeedback.js +++ b/src/components/OfflineWithFeedback.js @@ -50,8 +50,7 @@ const propTypes = { errorRowStyles: stylePropTypes, /** User draft to update message */ - // eslint-disable-next-line react/forbid-prop-types - draftMessage: PropTypes.any, + draftMessage: PropTypes.string, ...withLocalizePropTypes, }; From 479f12645279e9f80f3644fc159b9ce027bcdfce Mon Sep 17 00:00:00 2001 From: Furkan Date: Fri, 4 Nov 2022 11:08:29 +0300 Subject: [PATCH 3/3] reafactor: check draft message into current component,remove from common component --- src/components/OfflineWithFeedback.js | 6 +----- src/pages/home/report/ReportActionItem.js | 3 +-- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/src/components/OfflineWithFeedback.js b/src/components/OfflineWithFeedback.js index 006c8545e699..c02441f61ecd 100644 --- a/src/components/OfflineWithFeedback.js +++ b/src/components/OfflineWithFeedback.js @@ -49,15 +49,11 @@ const propTypes = { /** Additional style object for the error row */ errorRowStyles: stylePropTypes, - /** User draft to update message */ - draftMessage: PropTypes.string, - ...withLocalizePropTypes, }; const defaultProps = { pendingAction: null, - draftMessage: null, errors: null, shouldShowErrorMessages: true, onClose: () => {}, @@ -89,7 +85,7 @@ const OfflineWithFeedback = (props) => { const isOfflinePendingAction = props.network.isOffline && props.pendingAction; const isUpdateOrDeleteError = hasErrors && (props.pendingAction === 'delete' || props.pendingAction === 'update'); const isAddError = hasErrors && props.pendingAction === 'add'; - const needsOpacity = (isOfflinePendingAction && !isUpdateOrDeleteError && !props.draftMessage) || isAddError; + const needsOpacity = (isOfflinePendingAction && !isUpdateOrDeleteError) || isAddError; const needsStrikeThrough = props.network.isOffline && props.pendingAction === 'delete'; const hideChildren = !props.network.isOffline && props.pendingAction === 'delete' && !hasErrors; let children = props.children; diff --git a/src/pages/home/report/ReportActionItem.js b/src/pages/home/report/ReportActionItem.js index 0157d126e334..27302710b665 100644 --- a/src/pages/home/report/ReportActionItem.js +++ b/src/pages/home/report/ReportActionItem.js @@ -195,10 +195,9 @@ class ReportActionItem extends Component { ReportActions.clearReportActionErrors(this.props.report.reportID, this.props.action.sequenceNumber); } }} - pendingAction={this.props.action.pendingAction} + pendingAction={this.props.draftMessage ? null : this.props.action.pendingAction} errors={this.props.action.errors} errorRowStyles={[styles.ml10, styles.mr2]} - draftMessage={this.props.draftMessage} > {!this.props.displayAsGroup ? (