test(archive): month columns per culture, failure sentences, health against duplicates, RTL paths and keys, named buttons and focus
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
This commit is contained in:
3 files changed
+216
-14
No files matched your search
@@ -80,22 +80,26 @@ public partial class ArchiveView : UserControl
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// On a year: the arrow towards the indented side opens it (Right, or Left in a right-to-left layout, as a tree
|
||||
/// view does), the other arrow closes it, Enter toggles it.
|
||||
/// </summary>
|
||||
private void OnTreeKeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
if (Model is not { } model || Keyboard.FocusedElement is not ListBoxItem { DataContext: ArchiveTreeRowViewModel row } || !row.HasChildren || row.IsArchive) return;
|
||||
var (open, close) = Tree.FlowDirection == FlowDirection.RightToLeft ? (Key.Left, Key.Right) : (Key.Right, Key.Left);
|
||||
var toggle = e.Key == open ? !row.IsExpanded
|
||||
: e.Key == close ? row.IsExpanded
|
||||
: e.Key == Key.Enter;
|
||||
if (!toggle) return;
|
||||
if (!Toggles(e.Key, Tree.FlowDirection, row.IsExpanded)) return;
|
||||
model.Toggle(row);
|
||||
e.Handled = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Whether <paramref name="key"/> opens or closes a year: the arrow towards the indented side opens it (Right, or
|
||||
/// Left in a right-to-left layout, as a tree view does), the other arrow closes it, Enter toggles it.
|
||||
/// </summary>
|
||||
internal static bool Toggles(Key key, FlowDirection direction, bool isExpanded)
|
||||
{
|
||||
var (open, close) = direction == FlowDirection.RightToLeft ? (Key.Left, Key.Right) : (Key.Right, Key.Left);
|
||||
return key == open ? !isExpanded
|
||||
: key == close ? isExpanded
|
||||
: key == Key.Enter;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A dialog that opens takes the keyboard (its first field or button); when it closes, the keyboard goes back to the
|
||||
/// control that opened it, or to the tree when that control can no longer take it.
|
||||
|
||||
Reference in new issue
Block a user