mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-12-15 11:17:53 +01: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
@@ -1,4 +1,4 @@
|
||||
<!-- Copyright (c) Microsoft Corporation. All rights reserved. -->
|
||||
<!-- Copyright (c) Microsoft Corporation. All rights reserved. -->
|
||||
<!-- Licensed under the MIT License. See LICENSE in the project root for license information. -->
|
||||
|
||||
<UserControl
|
||||
@@ -96,6 +96,7 @@
|
||||
|
||||
<ItemsControl
|
||||
x:Name="ParametersItemsControl"
|
||||
IsTabStop="False"
|
||||
ItemTemplate="{StaticResource FormatParameterTemplate}"
|
||||
ItemsPanel="{StaticResource ItemPanelTemplate}" />
|
||||
|
||||
@@ -107,6 +108,7 @@
|
||||
|
||||
<ItemsControl
|
||||
x:Name="ColorParametersItemsControl"
|
||||
IsTabStop="False"
|
||||
ItemTemplate="{StaticResource ColorParameterTemplate}"
|
||||
ItemsPanel="{StaticResource ItemPanelTemplate}" />
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -424,10 +424,11 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
||||
return colorFormatModel.IsValid;
|
||||
}
|
||||
|
||||
internal void DeleteModel(ColorFormatModel colorFormatModel)
|
||||
internal int DeleteModel(ColorFormatModel colorFormatModel)
|
||||
{
|
||||
var deleteIndex = ColorFormats.IndexOf(colorFormatModel);
|
||||
ColorFormats.Remove(colorFormatModel);
|
||||
SetPreviewSelectedIndex();
|
||||
return deleteIndex;
|
||||
}
|
||||
|
||||
internal void UpdateColorFormat(string oldName, ColorFormatModel colorFormat)
|
||||
|
||||
Reference in New Issue
Block a user