mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-05 18:57:19 +02:00
[Settings]Colorpicker settings page focus a11y fixes (#32582)
* fixed dialog tab navigation * fixed color formats list focus
This commit is contained in:
committed by
GitHub
parent
5c352a3bf3
commit
cc4bd4486c
@@ -95,6 +95,7 @@
|
||||
<!-- Disabled reordering by dragging -->
|
||||
<!-- CanReorderItems="True" AllowDrop="True" -->
|
||||
<ItemsControl
|
||||
x:Name="ColorFormats"
|
||||
HorizontalAlignment="Stretch"
|
||||
AutomationProperties.Name="{Binding ElementName=ColorFormatsSetting, Path=Header}"
|
||||
IsTabStop="False"
|
||||
|
||||
@@ -63,7 +63,8 @@ namespace Microsoft.PowerToys.Settings.UI.Views
|
||||
var index = ViewModel.ColorFormats.IndexOf(color);
|
||||
if (index > 0)
|
||||
{
|
||||
ViewModel.ColorFormats.Move(index, index - 1);
|
||||
ViewModel.ColorFormats.Move(index, --index);
|
||||
SetColorFormatsFocus(index);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -78,7 +79,8 @@ namespace Microsoft.PowerToys.Settings.UI.Views
|
||||
var index = ViewModel.ColorFormats.IndexOf(color);
|
||||
if (index < ViewModel.ColorFormats.Count - 1)
|
||||
{
|
||||
ViewModel.ColorFormats.Move(index, index + 1);
|
||||
ViewModel.ColorFormats.Move(index, ++index);
|
||||
SetColorFormatsFocus(index);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -95,7 +97,8 @@ namespace Microsoft.PowerToys.Settings.UI.Views
|
||||
dialog.Content = new TextBlock() { Text = resourceLoader.GetString("Delete_Dialog_Description") };
|
||||
dialog.PrimaryButtonClick += (s, args) =>
|
||||
{
|
||||
ViewModel.DeleteModel(color);
|
||||
var deleteIndex = ViewModel.DeleteModel(color);
|
||||
SetColorFormatsFocus(deleteIndex < ViewModel.ColorFormats.Count ? deleteIndex : ViewModel.ColorFormats.Count - 1);
|
||||
};
|
||||
var result = await dialog.ShowAsync();
|
||||
}
|
||||
@@ -105,6 +108,7 @@ namespace Microsoft.PowerToys.Settings.UI.Views
|
||||
ColorFormatModel newColorFormat = ColorFormatDialog.DataContext as ColorFormatModel;
|
||||
ViewModel.AddNewColorFormat(newColorFormat.Name, newColorFormat.Format, true);
|
||||
ColorFormatDialog.Hide();
|
||||
SetColorFormatsFocus(0);
|
||||
}
|
||||
|
||||
private void Update()
|
||||
@@ -159,5 +163,12 @@ namespace Microsoft.PowerToys.Settings.UI.Views
|
||||
modifiedColorFormat.Format = oldProperties.Value;
|
||||
}
|
||||
}
|
||||
|
||||
private void SetColorFormatsFocus(int index)
|
||||
{
|
||||
ColorFormats.UpdateLayout();
|
||||
var colorFormat = ColorFormats.ContainerFromIndex(index) as ContentPresenter;
|
||||
colorFormat.Focus(Microsoft.UI.Xaml.FocusState.Programmatic);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user