From a2302a02ab766633a8df730782011c24eb29efcf Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Fri, 20 Sep 2019 13:12:28 +0200 Subject: [PATCH] Fix focusedChild null in MoveFocusFromClearedIndex. --- src/Avalonia.Controls/Repeater/ViewManager.cs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/Avalonia.Controls/Repeater/ViewManager.cs b/src/Avalonia.Controls/Repeater/ViewManager.cs index 833e708e9e..3e09a5b3ee 100644 --- a/src/Avalonia.Controls/Repeater/ViewManager.cs +++ b/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; }