Browse Source
Fixed focus not being cleared when a parent of the focused element is hidden (#18916)
Enabled the relevant test
pull/18929/head
Tom Edwards
9 months ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with
13 additions and
3 deletions
-
src/Avalonia.Base/Input/InputElement.cs
-
tests/Avalonia.Base.UnitTests/Input/InputElement_Focus.cs
|
|
|
@ -720,9 +720,19 @@ namespace Avalonia.Input |
|
|
|
{ |
|
|
|
PseudoClasses.Set(":focus-within", change.GetNewValue<bool>()); |
|
|
|
} |
|
|
|
else if (change.Property == IsVisibleProperty && !change.GetNewValue<bool>() && IsFocused) |
|
|
|
else if (change.Property == IsVisibleProperty) |
|
|
|
{ |
|
|
|
FocusManager.GetFocusManager(this)?.ClearFocus(); |
|
|
|
if (!change.GetNewValue<bool>() && IsKeyboardFocusWithin && FocusManager.GetFocusManager(this) is { } focusManager) |
|
|
|
{ |
|
|
|
if (focusManager.GetFocusedElement() is { } focusedElement && VisualParent != null) |
|
|
|
{ |
|
|
|
focusManager.ClearFocusOnElementRemoved(focusedElement, VisualParent); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
focusManager.ClearFocus(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -203,7 +203,7 @@ namespace Avalonia.Base.UnitTests.Input |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
[Fact(Skip = "Need to implement IsEffectivelyVisible change notifications.")] |
|
|
|
[Fact] |
|
|
|
public void Focus_Should_Be_Cleared_When_Control_Is_Effectively_Hidden() |
|
|
|
{ |
|
|
|
Border container; |
|
|
|
|