Skip to content

Commit a5ca73f

Browse files
authored
Fixed several rename issues (#1736)
1 parent 86e99b3 commit a5ca73f

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

Files/Views/LayoutModes/GenericFileBrowser.xaml.cs

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -251,9 +251,14 @@ private void AllView_PreparingCellForEdit(object sender, DataGridPreparingCellFo
251251

252252
if (AppSettings.DoubleTapToRenameFiles == false) // Check if the double tap to rename files setting is off
253253
{
254-
AllView.CancelEdit(); // Cancel the edit operation
255-
App.CurrentInstance.InteractionOperations.OpenItem_Click(null, null); // Open the file instead
256-
return;
254+
// Only cancel if this event was triggered by a tap
255+
// Do not cancel when user presses F2 or context menu
256+
if (e.EditingEventArgs is TappedRoutedEventArgs)
257+
{
258+
AllView.CancelEdit(); // Cancel the edit operation
259+
App.CurrentInstance.InteractionOperations.OpenItem_Click(null, null); // Open the file instead
260+
return;
261+
}
257262
}
258263

259264
int extensionLength = SelectedItem.FileExtension?.Length ?? 0;
@@ -288,7 +293,7 @@ private void TextBox_TextChanged(object sender, TextChangedEventArgs e)
288293

289294
private async void AllView_CellEditEnding(object sender, DataGridCellEditEndingEventArgs e)
290295
{
291-
if (e.EditAction == DataGridEditAction.Cancel)
296+
if (e.EditAction == DataGridEditAction.Cancel || renamingTextBox == null)
292297
{
293298
return;
294299
}
@@ -308,7 +313,10 @@ private async void AllView_CellEditEnding(object sender, DataGridCellEditEndingE
308313

309314
private void AllView_CellEditEnded(object sender, DataGridCellEditEndedEventArgs e)
310315
{
311-
renamingTextBox.TextChanged -= TextBox_TextChanged;
316+
if (renamingTextBox != null)
317+
{
318+
renamingTextBox.TextChanged -= TextBox_TextChanged;
319+
}
312320
FileNameTeachingTip.IsOpen = false;
313321
isRenamingItem = false;
314322
}

0 commit comments

Comments
 (0)