mirror of
https://github.com/microsoft/PowerToys
synced 2025-08-28 13:07:44 +00:00
Dismiss the details pane when the list gets emptied (#39206)
I cannot find an issue for this. I swear I filed it somewhere. If you open winget, search for "terminal", wait till it loads, then hit `esc`, we'll clear the search and empty the list, but never actually hide the details pane. That looks weird. This fixes that. Closes _nothing i guess_.
This commit is contained in:
parent
83817700e1
commit
2c555e2c2b
@ -328,7 +328,19 @@ public partial class ListViewModel : PageViewModel, IDisposable
|
|||||||
}
|
}
|
||||||
|
|
||||||
[RelayCommand]
|
[RelayCommand]
|
||||||
private void UpdateSelectedItem(ListItemViewModel item)
|
private void UpdateSelectedItem(ListItemViewModel? item)
|
||||||
|
{
|
||||||
|
if (item != null)
|
||||||
|
{
|
||||||
|
SetSelectedItem(item);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ClearSelectedItem();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SetSelectedItem(ListItemViewModel item)
|
||||||
{
|
{
|
||||||
if (!item.SafeSlowInit())
|
if (!item.SafeSlowInit())
|
||||||
{
|
{
|
||||||
@ -357,6 +369,23 @@ public partial class ListViewModel : PageViewModel, IDisposable
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void ClearSelectedItem()
|
||||||
|
{
|
||||||
|
// GH #322:
|
||||||
|
// For inexplicable reasons, if you try updating the command bar and
|
||||||
|
// the details on the same UI thread tick as updating the list, we'll
|
||||||
|
// explode
|
||||||
|
DoOnUiThread(
|
||||||
|
() =>
|
||||||
|
{
|
||||||
|
WeakReferenceMessenger.Default.Send<UpdateCommandBarMessage>(new(null));
|
||||||
|
|
||||||
|
WeakReferenceMessenger.Default.Send<HideDetailsMessage>();
|
||||||
|
|
||||||
|
TextToSuggest = string.Empty;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
public override void InitializeProperties()
|
public override void InitializeProperties()
|
||||||
{
|
{
|
||||||
base.InitializeProperties();
|
base.InitializeProperties();
|
||||||
|
@ -124,14 +124,12 @@ public sealed partial class ListPage : Page,
|
|||||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("CodeQuality", "IDE0051:Remove unused private members", Justification = "VS is too aggressive at pruning methods bound in XAML")]
|
[System.Diagnostics.CodeAnalysis.SuppressMessage("CodeQuality", "IDE0051:Remove unused private members", Justification = "VS is too aggressive at pruning methods bound in XAML")]
|
||||||
private void ItemsList_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
private void ItemsList_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||||
{
|
{
|
||||||
if (ItemsList.SelectedItem is ListItemViewModel item)
|
var vm = ViewModel;
|
||||||
|
var li = ItemsList.SelectedItem as ListItemViewModel;
|
||||||
|
_ = Task.Run(() =>
|
||||||
{
|
{
|
||||||
var vm = ViewModel;
|
vm?.UpdateSelectedItemCommand.Execute(li);
|
||||||
_ = Task.Run(() =>
|
});
|
||||||
{
|
|
||||||
vm?.UpdateSelectedItemCommand.Execute(item);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// There's mysterious behavior here, where the selection seemingly
|
// There's mysterious behavior here, where the selection seemingly
|
||||||
// changes to _nothing_ when we're backspacing to a single character.
|
// changes to _nothing_ when we're backspacing to a single character.
|
||||||
|
@ -418,9 +418,6 @@ public sealed partial class ShellPage : Microsoft.UI.Xaml.Controls.Page,
|
|||||||
{
|
{
|
||||||
_ = DispatcherQueue.TryEnqueue(() =>
|
_ = DispatcherQueue.TryEnqueue(() =>
|
||||||
{
|
{
|
||||||
// Also hide our details pane about here, if we had one
|
|
||||||
HideDetails();
|
|
||||||
|
|
||||||
if (_settingsWindow == null)
|
if (_settingsWindow == null)
|
||||||
{
|
{
|
||||||
_settingsWindow = new SettingsWindow();
|
_settingsWindow = new SettingsWindow();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user