Skip to content

Commit fb2006f

Browse files
committed
ux: focus input-less popups so Space in Discard dialog no longer stages the file behind it
1 parent 7384cc1 commit fb2006f

1 file changed

Lines changed: 19 additions & 1 deletion

File tree

src/Views/PopupDataTemplates.cs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
using Avalonia.Controls;
1+
using System.Linq;
2+
3+
using Avalonia.Controls;
24
using Avalonia.Controls.Templates;
35
using Avalonia.Input;
46
using Avalonia.VisualTree;
@@ -35,6 +37,22 @@ public Control Build(object param)
3537
return;
3638
}
3739
}
40+
41+
var host = ctl.GetVisualAncestors().OfType<Control>().FirstOrDefault(c => c.Name == "PopupPanel");
42+
if (host == null)
43+
return;
44+
45+
foreach (var input in host.GetVisualDescendants())
46+
{
47+
if (input is SelectableTextBlock)
48+
continue;
49+
50+
if (input is Control { Focusable: true, IsVisible: true, IsEffectivelyVisible: true, IsEffectivelyEnabled: true } focusable)
51+
{
52+
focusable.Focus(NavigationMethod.Directional);
53+
return;
54+
}
55+
}
3856
};
3957

4058
return control;

0 commit comments

Comments
 (0)