feat: try to focus on dialog and make tab navigation cycled.

This commit is contained in:
rabbitism
2024-09-01 16:26:43 +08:00
parent fb0816b2c5
commit 36aa3b9dec
5 changed files with 17 additions and 2 deletions

View File

@@ -1,5 +1,6 @@
using Avalonia;
using Avalonia.Input;
using Avalonia.VisualTree;
using Irihi.Avalonia.Shared.Helpers;
using Irihi.Avalonia.Shared.Shapes;
using Ursa.Controls.OverlayShared;
@@ -170,6 +171,9 @@ public partial class OverlayDialogHost
{
_maskAppearAnimation.RunAsync(mask);
}
var element = control.GetVisualDescendants().OfType<InputElement>().FirstOrDefault(a => a.Focusable);
element?.Focus();
_modalCount++;
IsInModalStatus = _modalCount > 0;
control.IsClosed = false;

View File

@@ -20,7 +20,7 @@ public abstract class OverlayFeedbackElement: ContentControl
static OverlayFeedbackElement()
{
FocusableProperty.OverrideDefaultValue<OverlayFeedbackElement>(true);
FocusableProperty.OverrideDefaultValue<OverlayFeedbackElement>(false);
DataContextProperty.Changed.AddClassHandler<OverlayFeedbackElement, object?>((o, e) => o.OnDataContextChange(e));
ClosedEvent.AddClassHandler<OverlayFeedbackElement>((o,e)=>o.OnClosed(e));
}