From dfe0fe0340c73067dde50d2eaa4cf132d9e43b97 Mon Sep 17 00:00:00 2001 From: Terry Sutton Date: Tue, 13 Feb 2024 18:13:10 -0330 Subject: [PATCH] Better storage file renaming (#21231) --- .../Storage/StorageExplorer/FileExplorerRowEditing.tsx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/apps/studio/components/to-be-cleaned/Storage/StorageExplorer/FileExplorerRowEditing.tsx b/apps/studio/components/to-be-cleaned/Storage/StorageExplorer/FileExplorerRowEditing.tsx index bf55400b800..176f0388d6a 100644 --- a/apps/studio/components/to-be-cleaned/Storage/StorageExplorer/FileExplorerRowEditing.tsx +++ b/apps/studio/components/to-be-cleaned/Storage/StorageExplorer/FileExplorerRowEditing.tsx @@ -34,7 +34,13 @@ const FileExplorerRowEditing = ({ item, view, columnIndex }: FileExplorerRowEdit } useEffect(() => { - if (inputRef.current) inputRef.current.select() + // select just the name of the file without the extension + if (inputRef.current) { + const dotIndex = item.name.lastIndexOf('.') + const selectionEnd = dotIndex !== -1 ? dotIndex : item.name.length + inputRef.current.setSelectionRange(0, selectionEnd) + inputRef.current.focus() + } // [Joshen] Esc should revert changes const handleEsc = (event: KeyboardEvent) => {