From fb2006f2d36963854c0f1d1beb2c547d78089b69 Mon Sep 17 00:00:00 2001 From: corebonts Date: Sat, 5 Sep 2026 18:13:53 +0200 Subject: [PATCH] ux: focus input-less popups so Space in Discard dialog no longer stages the file behind it --- src/Views/PopupDataTemplates.cs | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/Views/PopupDataTemplates.cs b/src/Views/PopupDataTemplates.cs index bfb2673aa0..ffb20904cf 100644 --- a/src/Views/PopupDataTemplates.cs +++ b/src/Views/PopupDataTemplates.cs @@ -1,4 +1,6 @@ -using Avalonia.Controls; +using System.Linq; + +using Avalonia.Controls; using Avalonia.Controls.Templates; using Avalonia.Input; using Avalonia.VisualTree; @@ -35,6 +37,22 @@ public Control Build(object param) return; } } + + var host = ctl.GetVisualAncestors().OfType().FirstOrDefault(c => c.Name == "PopupPanel"); + if (host == null) + return; + + foreach (var input in host.GetVisualDescendants()) + { + if (input is SelectableTextBlock) + continue; + + if (input is Control { Focusable: true, IsVisible: true, IsEffectivelyVisible: true, IsEffectivelyEnabled: true } focusable) + { + focusable.Focus(NavigationMethod.Directional); + return; + } + } }; return control;