From b9c9d602de3b940044ff7f669180d0630af626b9 Mon Sep 17 00:00:00 2001 From: Will Miao <13051207myq@gmail.com> Date: Thu, 22 May 2025 11:07:52 +0800 Subject: [PATCH] Enhance download modals: auto-focus on URL input and auto-select version if only one available --- static/js/managers/CheckpointDownloadManager.js | 13 +++++++++++++ static/js/managers/DownloadManager.js | 13 +++++++++++++ 2 files changed, 26 insertions(+) diff --git a/static/js/managers/CheckpointDownloadManager.js b/static/js/managers/CheckpointDownloadManager.js index a5af71bf..37f4081f 100644 --- a/static/js/managers/CheckpointDownloadManager.js +++ b/static/js/managers/CheckpointDownloadManager.js @@ -36,6 +36,14 @@ export class CheckpointDownloadManager { this.cleanupFolderBrowser(); }); this.resetSteps(); + + // Auto-focus on the URL input + setTimeout(() => { + const urlInput = document.getElementById('checkpointUrl'); + if (urlInput) { + urlInput.focus(); + } + }, 100); // Small delay to ensure the modal is fully displayed } resetSteps() { @@ -178,6 +186,11 @@ export class CheckpointDownloadManager { `; }).join(''); + // Auto-select the version if there's only one + if (this.versions.length === 1 && !this.currentVersion) { + this.selectVersion(this.versions[0].id.toString()); + } + // Update Next button state based on initial selection this.updateNextButtonState(); } diff --git a/static/js/managers/DownloadManager.js b/static/js/managers/DownloadManager.js index b489b69a..24fa7528 100644 --- a/static/js/managers/DownloadManager.js +++ b/static/js/managers/DownloadManager.js @@ -38,6 +38,14 @@ export class DownloadManager { this.cleanupFolderBrowser(); }); this.resetSteps(); + + // Auto-focus on the URL input + setTimeout(() => { + const urlInput = document.getElementById('loraUrl'); + if (urlInput) { + urlInput.focus(); + } + }, 100); // Small delay to ensure the modal is fully displayed } resetSteps() { @@ -182,6 +190,11 @@ export class DownloadManager { `; }).join(''); + // Auto-select the version if there's only one + if (this.versions.length === 1 && !this.currentVersion) { + this.selectVersion(this.versions[0].id.toString()); + } + // Update Next button state based on initial selection this.updateNextButtonState(); }