File tree Expand file tree Collapse file tree 2 files changed +13
-3
lines changed
tests/Avalonia.Base.UnitTests/Input Expand file tree Collapse file tree 2 files changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -720,9 +720,19 @@ protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs chang
720
720
{
721
721
PseudoClasses . Set ( ":focus-within" , change . GetNewValue < bool > ( ) ) ;
722
722
}
723
- else if ( change . Property == IsVisibleProperty && ! change . GetNewValue < bool > ( ) && IsFocused )
723
+ else if ( change . Property == IsVisibleProperty )
724
724
{
725
- FocusManager . GetFocusManager ( this ) ? . ClearFocus ( ) ;
725
+ if ( ! change . GetNewValue < bool > ( ) && IsKeyboardFocusWithin && FocusManager . GetFocusManager ( this ) is { } focusManager )
726
+ {
727
+ if ( focusManager . GetFocusedElement ( ) is { } focusedElement && VisualParent != null )
728
+ {
729
+ focusManager . ClearFocusOnElementRemoved ( focusedElement , VisualParent ) ;
730
+ }
731
+ else
732
+ {
733
+ focusManager . ClearFocus ( ) ;
734
+ }
735
+ }
726
736
}
727
737
}
728
738
Original file line number Diff line number Diff line change @@ -203,7 +203,7 @@ public void Focus_Should_Be_Cleared_When_Control_Is_Hidden()
203
203
}
204
204
}
205
205
206
- [ Fact ( Skip = "Need to implement IsEffectivelyVisible change notifications." ) ]
206
+ [ Fact ]
207
207
public void Focus_Should_Be_Cleared_When_Control_Is_Effectively_Hidden ( )
208
208
{
209
209
Border container ;
You can’t perform that action at this time.
0 commit comments