From 4bf9a4b64063f04782be3aff5aa3c66d50737741 Mon Sep 17 00:00:00 2001 From: Will Miao Date: Sat, 8 Aug 2026 08:50:36 +0800 Subject: [PATCH] refactor(download): rename locationStep id to downloadLocationStep The download modal's step shared the 'locationStep' id with the import modal, so getElementById('locationStep') could resolve to the wrong element depending on template include order. The import flow relied on an injected display:block !important rule to work around it. Rename the download modal's step id and update all references so each modal owns a unique step id. --- static/js/managers/DownloadManager.js | 6 +++--- static/js/managers/import/ImportStepManager.js | 7 ++----- templates/components/modals/download_modal.html | 2 +- .../managers/downloadManager.latestVersion.test.js | 2 +- 4 files changed, 7 insertions(+), 10 deletions(-) diff --git a/static/js/managers/DownloadManager.js b/static/js/managers/DownloadManager.js index 068aae8d..71578d26 100644 --- a/static/js/managers/DownloadManager.js +++ b/static/js/managers/DownloadManager.js @@ -754,7 +754,7 @@ export class DownloadManager { this.selectedFile?.id, this.selectedFile?.name, this.selectedFile?.type, this.selectedFile?.metadata); document.getElementById('fileSelectionStep').style.display = 'none'; - document.getElementById('locationStep').style.display = 'block'; + document.getElementById('downloadLocationStep').style.display = 'block'; this.proceedToLocationContent(); } @@ -788,7 +788,7 @@ export class DownloadManager { } document.querySelectorAll('.download-step').forEach(step => step.style.display = 'none'); - document.getElementById('locationStep').style.display = 'block'; + document.getElementById('downloadLocationStep').style.display = 'block'; await this.proceedToLocationContent(); } @@ -1563,7 +1563,7 @@ export class DownloadManager { } backToVersions() { - document.getElementById('locationStep').style.display = 'none'; + document.getElementById('downloadLocationStep').style.display = 'none'; if (this.isBatchMode) { document.getElementById('batchPreviewStep').style.display = 'block'; } else { diff --git a/static/js/managers/import/ImportStepManager.js b/static/js/managers/import/ImportStepManager.js index 8af2978b..d5b8e47d 100644 --- a/static/js/managers/import/ImportStepManager.js +++ b/static/js/managers/import/ImportStepManager.js @@ -47,11 +47,8 @@ export class ImportStepManager { targetStep.offsetHeight; } - // Reset scroll via class: 'locationStep' has a duplicate ID in downloadModal's - // template, so getElementById may not return the import modal's step. - document.querySelectorAll('.import-step').forEach(step => { - step.scrollTop = 0; - }); + // Scroll the active step back to top (steps scroll independently of the modal shell) + targetStep.scrollTop = 0; } } } diff --git a/templates/components/modals/download_modal.html b/templates/components/modals/download_modal.html index b09acdb2..f92f3230 100644 --- a/templates/components/modals/download_modal.html +++ b/templates/components/modals/download_modal.html @@ -60,7 +60,7 @@ -