From ad0916839b5150070800b1fb789d308355388c6c Mon Sep 17 00:00:00 2001 From: aparriaran Date: Thu, 14 Nov 2024 21:34:40 -0600 Subject: [PATCH 1/3] =?UTF-8?q?Fixed=20the=20Crash=20with=20=E2=80=9Cdocum?= =?UTF-8?q?ent.getElementById(...)=20is=20null=E2=80=9D=20as=20error=20by?= =?UTF-8?q?=20adding=20a=20condition=20to=20see=20if=20the=20element=20exi?= =?UTF-8?q?sts=20before=20we=20remove=20the=20attribute.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Admin/View/ViewAssessmentTask/ViewAssessmentTasks.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/FrontEndReact/src/View/Admin/View/ViewAssessmentTask/ViewAssessmentTasks.js b/FrontEndReact/src/View/Admin/View/ViewAssessmentTask/ViewAssessmentTasks.js index e85649546..da6924348 100644 --- a/FrontEndReact/src/View/Admin/View/ViewAssessmentTask/ViewAssessmentTasks.js +++ b/FrontEndReact/src/View/Admin/View/ViewAssessmentTask/ViewAssessmentTasks.js @@ -54,6 +54,7 @@ class ViewAssessmentTasks extends Component { const blob = new Blob([fileData], { type: 'csv' }); const url = URL.createObjectURL(blob); + const exportAssessmentTask = document.getElementById(this.state.exportButtonId[assessmentName]) const link = document.createElement("a"); link.download = this.state.downloadedAssessment + ".csv"; @@ -62,9 +63,11 @@ class ViewAssessmentTasks extends Component { link.click(); var assessmentName = this.state.downloadedAssessment; - + setTimeout(() => { - document.getElementById(this.state.exportButtonId[assessmentName]).removeAttribute("disabled"); + if(exportAssessmentTask) { + exportAssessmentTask.removeAttribute("disabled"); + } }, 10000); this.setState({ From a1edc91c5929e755e02d1ff692a1c2e9116f9c92 Mon Sep 17 00:00:00 2001 From: aparriaran Date: Thu, 14 Nov 2024 21:43:44 -0600 Subject: [PATCH 2/3] Fixed ESLint Error by moving the exportAssessmentTask variable below. --- .../Admin/View/ViewAssessmentTask/ViewAssessmentTasks.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/FrontEndReact/src/View/Admin/View/ViewAssessmentTask/ViewAssessmentTasks.js b/FrontEndReact/src/View/Admin/View/ViewAssessmentTask/ViewAssessmentTasks.js index da6924348..a99474001 100644 --- a/FrontEndReact/src/View/Admin/View/ViewAssessmentTask/ViewAssessmentTasks.js +++ b/FrontEndReact/src/View/Admin/View/ViewAssessmentTask/ViewAssessmentTasks.js @@ -54,16 +54,17 @@ class ViewAssessmentTasks extends Component { const blob = new Blob([fileData], { type: 'csv' }); const url = URL.createObjectURL(blob); - const exportAssessmentTask = document.getElementById(this.state.exportButtonId[assessmentName]) - + const link = document.createElement("a"); link.download = this.state.downloadedAssessment + ".csv"; link.href = url; link.setAttribute('download', 'export.csv'); link.click(); - + var assessmentName = this.state.downloadedAssessment; + const exportAssessmentTask = document.getElementById(this.state.exportButtonId[assessmentName]) + setTimeout(() => { if(exportAssessmentTask) { exportAssessmentTask.removeAttribute("disabled"); From a547ac6ca4d66d6d1ea8306d3250a9c410e948c2 Mon Sep 17 00:00:00 2001 From: ebanderson3 Date: Fri, 15 Nov 2024 11:06:26 -0600 Subject: [PATCH 3/3] Removed some unneeded tabs --- .../View/Admin/View/ViewAssessmentTask/ViewAssessmentTasks.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/FrontEndReact/src/View/Admin/View/ViewAssessmentTask/ViewAssessmentTasks.js b/FrontEndReact/src/View/Admin/View/ViewAssessmentTask/ViewAssessmentTasks.js index a99474001..5da840d90 100644 --- a/FrontEndReact/src/View/Admin/View/ViewAssessmentTask/ViewAssessmentTasks.js +++ b/FrontEndReact/src/View/Admin/View/ViewAssessmentTask/ViewAssessmentTasks.js @@ -54,13 +54,13 @@ class ViewAssessmentTasks extends Component { const blob = new Blob([fileData], { type: 'csv' }); const url = URL.createObjectURL(blob); - + const link = document.createElement("a"); link.download = this.state.downloadedAssessment + ".csv"; link.href = url; link.setAttribute('download', 'export.csv'); link.click(); - + var assessmentName = this.state.downloadedAssessment; const exportAssessmentTask = document.getElementById(this.state.exportButtonId[assessmentName])