From 146c25752daf909f88162192d8878e53477ed12c Mon Sep 17 00:00:00 2001 From: marlenhalvorsen Date: Mon, 8 Dec 2025 20:52:48 +0100 Subject: [PATCH 1/3] feat: set 'New folder' as default name + auto-select when creating new folder --- src/Files.App/Helpers/Dialog/DynamicDialogFactory.cs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/Files.App/Helpers/Dialog/DynamicDialogFactory.cs b/src/Files.App/Helpers/Dialog/DynamicDialogFactory.cs index 9bf5ed995848..287a07124585 100644 --- a/src/Files.App/Helpers/Dialog/DynamicDialogFactory.cs +++ b/src/Files.App/Helpers/Dialog/DynamicDialogFactory.cs @@ -96,7 +96,16 @@ public static DynamicDialog GetFor_CreateItemDialog(string itemType) inputText.Loaded += (s, e) => { // dispatching to the ui thread fixes an issue where the primary dialog button would steal focus - _ = inputText.DispatcherQueue.EnqueueOrInvokeAsync(() => inputText.Focus(FocusState.Programmatic)); + _ = inputText.DispatcherQueue.EnqueueOrInvokeAsync(() => + { + if(itemType.Equals("Folder", StringComparison.OrdinalIgnoreCase)) + { + inputText.Text = Strings.NewFolder.GetLocalizedResource(); + } + + inputText.Focus(FocusState.Programmatic); + inputText.SelectAll(); + }); }; dialog = new DynamicDialog(new DynamicDialogViewModel() From 24ec2f9c63fb13ff48c633b5dccc58f717e9a5af Mon Sep 17 00:00:00 2001 From: marlenhalvorsen Date: Tue, 9 Dec 2025 08:53:18 +0100 Subject: [PATCH 2/3] fix: add subtitle 'Enter an item name' to create item dialog --- src/Files.App/Helpers/Dialog/DynamicDialogFactory.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Files.App/Helpers/Dialog/DynamicDialogFactory.cs b/src/Files.App/Helpers/Dialog/DynamicDialogFactory.cs index 287a07124585..02d059473062 100644 --- a/src/Files.App/Helpers/Dialog/DynamicDialogFactory.cs +++ b/src/Files.App/Helpers/Dialog/DynamicDialogFactory.cs @@ -111,7 +111,7 @@ public static DynamicDialog GetFor_CreateItemDialog(string itemType) dialog = new DynamicDialog(new DynamicDialogViewModel() { TitleText = string.Format(Strings.CreateNewItemTitle.GetLocalizedResource(), itemType), - SubtitleText = null, + SubtitleText = Strings.EnterAnItemName.GetLocalizedResource(), DisplayControl = new Grid() { MinWidth = 300d, From 2340848e60c77b35c9538198e22df3379778d918 Mon Sep 17 00:00:00 2001 From: Yair <39923744+yaira2@users.noreply.github.com> Date: Tue, 16 Dec 2025 18:25:43 -0500 Subject: [PATCH 3/3] Prefill new item dialog with default name Updated the create item dialog to prefill the input box with a default name for files and folders. Added a new resource string for file creation and modified dialog factory and UI helpers to support passing the item name. Update DynamicDialogFactory.cs --- .../Helpers/Dialog/DynamicDialogFactory.cs | 13 +++++++------ src/Files.App/Helpers/UI/UIFilesystemHelpers.cs | 2 +- src/Files.App/Strings/en-US/Resources.resw | 3 +++ 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/Files.App/Helpers/Dialog/DynamicDialogFactory.cs b/src/Files.App/Helpers/Dialog/DynamicDialogFactory.cs index 02d059473062..e13d792a8f20 100644 --- a/src/Files.App/Helpers/Dialog/DynamicDialogFactory.cs +++ b/src/Files.App/Helpers/Dialog/DynamicDialogFactory.cs @@ -55,7 +55,7 @@ public static DynamicDialog GetFor_ShortcutNotFound(string targetPath) return dialog; } - public static DynamicDialog GetFor_CreateItemDialog(string itemType) + public static DynamicDialog GetFor_CreateItemDialog(string itemType, string? itemName) { DynamicDialog? dialog = null; TextBox inputText = new() @@ -95,13 +95,14 @@ public static DynamicDialog GetFor_CreateItemDialog(string itemType) inputText.Loaded += (s, e) => { - // dispatching to the ui thread fixes an issue where the primary dialog button would steal focus - _ = inputText.DispatcherQueue.EnqueueOrInvokeAsync(() => + // Dispatching to the UI thread fixes an issue where the primary dialog button would steal focus + _ = inputText.DispatcherQueue.EnqueueOrInvokeAsync(() => { - if(itemType.Equals("Folder", StringComparison.OrdinalIgnoreCase)) - { + // Prefill text box with default name #17845 + if (itemType.Equals("Folder", StringComparison.OrdinalIgnoreCase)) inputText.Text = Strings.NewFolder.GetLocalizedResource(); - } + else if (itemName is not null) + inputText.Text = string.Format(Strings.CreateNewFile.GetLocalizedResource(), itemName); inputText.Focus(FocusState.Programmatic); inputText.SelectAll(); diff --git a/src/Files.App/Helpers/UI/UIFilesystemHelpers.cs b/src/Files.App/Helpers/UI/UIFilesystemHelpers.cs index 74ec1ccb8330..0d819b7b109c 100644 --- a/src/Files.App/Helpers/UI/UIFilesystemHelpers.cs +++ b/src/Files.App/Helpers/UI/UIFilesystemHelpers.cs @@ -107,7 +107,7 @@ public static async Task CreateFileFromDialogResultTypeAsync(AddItemDialogItemTy string? userInput = null; if (itemType != AddItemDialogItemType.File || itemInfo?.Command is null) { - DynamicDialog dialog = DynamicDialogFactory.GetFor_CreateItemDialog(itemType.ToString().GetLocalizedResource().ToLower()); + DynamicDialog dialog = DynamicDialogFactory.GetFor_CreateItemDialog(itemType.ToString().GetLocalizedResource().ToLower(), itemInfo?.Name); await dialog.TryShowAsync(); // Show rename dialog if (dialog.DynamicResult != DynamicDialogResult.Primary) diff --git a/src/Files.App/Strings/en-US/Resources.resw b/src/Files.App/Strings/en-US/Resources.resw index a94b1f51aef8..38a948eaa110 100644 --- a/src/Files.App/Strings/en-US/Resources.resw +++ b/src/Files.App/Strings/en-US/Resources.resw @@ -4347,4 +4347,7 @@ Only in Columns View + + New {0} + \ No newline at end of file