diff --git a/assets/js/Components/App.js b/assets/js/Components/App.js index 6985d55b..03fd049f 100644 --- a/assets/js/Components/App.js +++ b/assets/js/Components/App.js @@ -217,14 +217,20 @@ class App extends React.Component { } handleIssueSave(newIssue, newReport) { - let { report } = this.state - report = {...report, ...newReport} + const oldReport = this.state.report; + + const report = {...oldReport, ...newReport}; if (report && Array.isArray(report.issues)) { - report.issues = report.issues.map(issue => (issue.id == newIssue.id) ? newIssue : issue) + // Combine backend issues with frontend issue state + report.issues = report.issues.map((issue) => { + if (issue.id === newIssue.id) return newIssue; + const oldIssue = oldReport.issues.find(oldReportIssue => oldReportIssue.id === issue.id); + return oldIssue !== undefined ? { ...oldIssue, ...issue } : issue; + }); } - this.setState({ report }) + this.setState({ report }); } handleFileSave(newFile, newReport) { diff --git a/assets/js/Components/ContentPage.js b/assets/js/Components/ContentPage.js index 38b4d5cf..410bbb43 100644 --- a/assets/js/Components/ContentPage.js +++ b/assets/js/Components/ContentPage.js @@ -102,9 +102,17 @@ class ContentPage extends React.Component { } handleCloseButton = () => { + const newReport = { ...this.props.report }; + newReport.issues = newReport.issues.map(issue => { + issue.recentlyResolved = false; + issue.recentlyUpdated = false; + return issue; + }); + this.setState({ + report: newReport, modalOpen: false - }) + }); } handleTrayToggle = (e, val) => {