From c0dc0ce39114b1de7d92d63facc0c7239ae085cb Mon Sep 17 00:00:00 2001 From: Ryan Date: Mon, 24 Mar 2025 16:53:37 -0400 Subject: [PATCH] Rename file modal select and focus filename --- fileManager.js | 10 ++++++++++ trashRestoreDelete.js | 11 ----------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/fileManager.js b/fileManager.js index 5ebdfb6..df8d219 100644 --- a/fileManager.js +++ b/fileManager.js @@ -1203,6 +1203,16 @@ export function renameFile(oldName, folder) { window.fileFolder = folder || window.currentFolder || "root"; document.getElementById("newFileName").value = oldName; document.getElementById("renameFileModal").style.display = "block"; + setTimeout(() => { + const input = document.getElementById("newFileName"); + input.focus(); + const lastDot = oldName.lastIndexOf('.'); + if (lastDot > 0) { + input.setSelectionRange(0, lastDot); + } else { + input.select(); + } + }, 100); } document.addEventListener("DOMContentLoaded", () => { diff --git a/trashRestoreDelete.js b/trashRestoreDelete.js index dbc7c6c..31f21d2 100644 --- a/trashRestoreDelete.js +++ b/trashRestoreDelete.js @@ -4,20 +4,13 @@ import { toggleVisibility, showToast } from './domUtils.js'; import { loadFileList } from './fileManager.js'; import { loadFolderTree } from './folderManager.js'; -/** - * Displays a custom confirmation modal with the given message. - * Calls onConfirm() if the user confirms. - */ function showConfirm(message, onConfirm) { - // Assume your custom confirm modal exists with id "customConfirmModal" - // and has elements "confirmMessage", "confirmYesBtn", and "confirmNoBtn". const modal = document.getElementById("customConfirmModal"); const messageElem = document.getElementById("confirmMessage"); const yesBtn = document.getElementById("confirmYesBtn"); const noBtn = document.getElementById("confirmNoBtn"); if (!modal || !messageElem || !yesBtn || !noBtn) { - // Fallback to browser confirm if custom modal is not found. if (confirm(message)) { onConfirm(); } @@ -42,10 +35,6 @@ function showConfirm(message, onConfirm) { }); } -/** - * Sets up event listeners for trash restore and delete operations. - * This function should be called from main.js after authentication. - */ export function setupTrashRestoreDelete() { // --- Attach listener to the restore button (created in auth.js) to open the modal.