Browse Source

Fix "GetFocusManager" with some unit tests

pull/11407/head
Max Katz 3 years ago
parent
commit
d3fbc105af
  1. 2
      src/Avalonia.Base/Input/FocusManager.cs

2
src/Avalonia.Base/Input/FocusManager.cs

@ -196,7 +196,7 @@ namespace Avalonia.Input
{ {
// Element might not be a visual, and not attached to the root. // Element might not be a visual, and not attached to the root.
// But IFocusManager is always expected to be a FocusManager. // But IFocusManager is always expected to be a FocusManager.
return (FocusManager?)((IInputRoot?)(element as Visual)?.VisualRoot)?.FocusManager return (FocusManager?)((element as Visual)?.VisualRoot as IInputRoot)?.FocusManager
// In our unit tests some elements might not have a root. Remove when we migrate to headless tests. // In our unit tests some elements might not have a root. Remove when we migrate to headless tests.
?? (FocusManager?)AvaloniaLocator.Current.GetService<IFocusManager>(); ?? (FocusManager?)AvaloniaLocator.Current.GetService<IFocusManager>();
} }

Loading…
Cancel
Save