Skip to content

Commit a2dcb40

Browse files
authored
Fix: Fixed issue where the preview pane didn't update when switching panes (#12647)
1 parent fce2c63 commit a2dcb40

File tree

3 files changed

+33
-10
lines changed

3 files changed

+33
-10
lines changed

src/Files.App/Views/LayoutModes/BaseLayout.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ public string JumpString
188188
}
189189
}
190190

191-
protected bool LockPreviewPaneContent { get; set; }
191+
public bool LockPreviewPaneContent { get; set; }
192192

193193
private List<ListedItem>? selectedItems = new List<ListedItem>();
194194
public List<ListedItem>? SelectedItems

src/Files.App/Views/LayoutModes/IBaseLayout.cs

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,27 @@ public interface IBaseLayout : IDisposable
1313

1414
bool IsMiddleClickToScrollEnabled { get; set; }
1515

16-
public List<ListedItem>? SelectedItems { get; }
16+
/// <summary>
17+
/// If true, the preview pane is not updated when the selected item is changed.
18+
/// </summary>
19+
bool LockPreviewPaneContent { get; set; }
1720

18-
public ListedItem? SelectedItem { get; }
21+
List<ListedItem>? SelectedItems { get; }
22+
23+
ListedItem? SelectedItem { get; }
1924

2025
ItemManipulationModel ItemManipulationModel { get; }
2126

2227
PreviewPaneViewModel PreviewPaneViewModel { get; }
2328

24-
public SelectedItemsPropertiesViewModel SelectedItemsPropertiesViewModel { get; }
29+
SelectedItemsPropertiesViewModel SelectedItemsPropertiesViewModel { get; }
2530

26-
public DirectoryPropertiesViewModel DirectoryPropertiesViewModel { get; }
31+
DirectoryPropertiesViewModel DirectoryPropertiesViewModel { get; }
2732

28-
public BaseLayoutCommandsViewModel? CommandsViewModel { get; }
33+
BaseLayoutCommandsViewModel? CommandsViewModel { get; }
2934

30-
public CommandBarFlyout ItemContextMenuFlyout { get; set; }
35+
CommandBarFlyout ItemContextMenuFlyout { get; set; }
3136

32-
public CommandBarFlyout BaseContextMenuFlyout { get; set; }
37+
CommandBarFlyout BaseContextMenuFlyout { get; set; }
3338
}
3439
}

src/Files.App/Views/PaneHolderPage.xaml.cs

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -324,15 +324,33 @@ private void Pane_Loaded(object sender, RoutedEventArgs e)
324324
((UIElement)sender).GotFocus += Pane_GotFocus;
325325
}
326326

327-
private void Pane_GotFocus(object sender, RoutedEventArgs e)
327+
private async void Pane_GotFocus(object sender, RoutedEventArgs e)
328328
{
329329
var isLeftPane = sender == PaneLeft;
330330
if (isLeftPane && (PaneRight?.SlimContentPage?.IsItemSelected ?? false))
331+
{
332+
PaneRight.SlimContentPage.LockPreviewPaneContent = true;
331333
PaneRight.SlimContentPage.ItemManipulationModel.ClearSelection();
334+
PaneRight.SlimContentPage.LockPreviewPaneContent = false;
335+
}
332336
else if (!isLeftPane && (PaneLeft?.SlimContentPage?.IsItemSelected ?? false))
337+
{
338+
PaneLeft.SlimContentPage.LockPreviewPaneContent = true;
333339
PaneLeft.SlimContentPage.ItemManipulationModel.ClearSelection();
340+
PaneLeft.SlimContentPage.LockPreviewPaneContent = false;
341+
}
334342

335-
ActivePane = isLeftPane ? PaneLeft : PaneRight;
343+
var activePane = isLeftPane ? PaneLeft : PaneRight;
344+
if (ActivePane != activePane)
345+
{
346+
ActivePane = activePane;
347+
348+
if (ActivePane?.SlimContentPage is IBaseLayout page && !page.IsItemSelected)
349+
{
350+
page.PreviewPaneViewModel.IsItemSelected = false;
351+
await page.PreviewPaneViewModel.UpdateSelectedItemPreview();
352+
}
353+
}
336354
}
337355

338356
public void Dispose()

0 commit comments

Comments
 (0)