Browse Source

Fix focusedChild null in MoveFocusFromClearedIndex.

Steven Kirk 6 years ago
parent
commit
a2302a02ab
1 changed files with 3 additions and 4 deletions
  1. 3 4
      src/Avalonia.Controls/Repeater/ViewManager.cs

+ 3 - 4
src/Avalonia.Controls/Repeater/ViewManager.cs

@@ -128,8 +128,7 @@ namespace Avalonia.Controls
 
         private void MoveFocusFromClearedIndex(int clearedIndex)
         {
-            IControl focusedChild = null;
-            var focusCandidate = FindFocusCandidate(clearedIndex, focusedChild);
+            var focusCandidate = FindFocusCandidate(clearedIndex, out var focusedChild);
             if (focusCandidate != null)
             {
                 focusCandidate.Focus();
@@ -145,7 +144,7 @@ namespace Avalonia.Controls
             }
         }
 
-        IControl FindFocusCandidate(int clearedIndex, IControl focusedChild)
+        IControl FindFocusCandidate(int clearedIndex, out IControl focusedChild)
         {
             // Walk through all the children and find elements with index before and after the cleared index.
             // Note that during a delete the next element would now have the same index.
@@ -183,7 +182,7 @@ namespace Avalonia.Controls
 
             // TODO: Find the next element if one exists, if not use the previous element.
             // If the container itself is not focusable, find a descendent that is.
-
+            focusedChild = nextElement;
             return nextElement;
         }