Skip to content

Fix: Fixed issue where the preview pane didn't update when switching panes #12647

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Files.App/Views/LayoutModes/BaseLayout.cs
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ public string JumpString
}
}

protected bool LockPreviewPaneContent { get; set; }
public bool LockPreviewPaneContent { get; set; }

private List<ListedItem>? selectedItems = new List<ListedItem>();
public List<ListedItem>? SelectedItems
Expand Down
19 changes: 12 additions & 7 deletions src/Files.App/Views/LayoutModes/IBaseLayout.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,27 @@ public interface IBaseLayout : IDisposable

bool IsMiddleClickToScrollEnabled { get; set; }

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

public ListedItem? SelectedItem { get; }
List<ListedItem>? SelectedItems { get; }

ListedItem? SelectedItem { get; }

ItemManipulationModel ItemManipulationModel { get; }

PreviewPaneViewModel PreviewPaneViewModel { get; }

public SelectedItemsPropertiesViewModel SelectedItemsPropertiesViewModel { get; }
SelectedItemsPropertiesViewModel SelectedItemsPropertiesViewModel { get; }

public DirectoryPropertiesViewModel DirectoryPropertiesViewModel { get; }
DirectoryPropertiesViewModel DirectoryPropertiesViewModel { get; }

public BaseLayoutCommandsViewModel? CommandsViewModel { get; }
BaseLayoutCommandsViewModel? CommandsViewModel { get; }

public CommandBarFlyout ItemContextMenuFlyout { get; set; }
CommandBarFlyout ItemContextMenuFlyout { get; set; }

public CommandBarFlyout BaseContextMenuFlyout { get; set; }
CommandBarFlyout BaseContextMenuFlyout { get; set; }
}
}
22 changes: 20 additions & 2 deletions src/Files.App/Views/PaneHolderPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -324,15 +324,33 @@ private void Pane_Loaded(object sender, RoutedEventArgs e)
((UIElement)sender).GotFocus += Pane_GotFocus;
}

private void Pane_GotFocus(object sender, RoutedEventArgs e)
private async void Pane_GotFocus(object sender, RoutedEventArgs e)
{
var isLeftPane = sender == PaneLeft;
if (isLeftPane && (PaneRight?.SlimContentPage?.IsItemSelected ?? false))
{
PaneRight.SlimContentPage.LockPreviewPaneContent = true;
PaneRight.SlimContentPage.ItemManipulationModel.ClearSelection();
PaneRight.SlimContentPage.LockPreviewPaneContent = false;
}
else if (!isLeftPane && (PaneLeft?.SlimContentPage?.IsItemSelected ?? false))
{
PaneLeft.SlimContentPage.LockPreviewPaneContent = true;
PaneLeft.SlimContentPage.ItemManipulationModel.ClearSelection();
PaneLeft.SlimContentPage.LockPreviewPaneContent = false;
}

ActivePane = isLeftPane ? PaneLeft : PaneRight;
var activePane = isLeftPane ? PaneLeft : PaneRight;
if (ActivePane != activePane)
{
ActivePane = activePane;

if (ActivePane?.SlimContentPage is IBaseLayout page && !page.IsItemSelected)
{
page.PreviewPaneViewModel.IsItemSelected = false;
await page.PreviewPaneViewModel.UpdateSelectedItemPreview();
}
}
}

public void Dispose()
Expand Down