Browse Source

Fix focusedChild null in MoveFocusFromClearedIndex.

pull/3017/head
Steven Kirk 7 years ago
parent
commit
a2302a02ab
  1. 7
      src/Avalonia.Controls/Repeater/ViewManager.cs

7
src/Avalonia.Controls/Repeater/ViewManager.cs

@ -128,8 +128,7 @@ namespace Avalonia.Controls
private void MoveFocusFromClearedIndex(int clearedIndex) private void MoveFocusFromClearedIndex(int clearedIndex)
{ {
IControl focusedChild = null; var focusCandidate = FindFocusCandidate(clearedIndex, out var focusedChild);
var focusCandidate = FindFocusCandidate(clearedIndex, focusedChild);
if (focusCandidate != null) if (focusCandidate != null)
{ {
focusCandidate.Focus(); 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. // 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. // 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. // 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. // If the container itself is not focusable, find a descendent that is.
focusedChild = nextElement;
return nextElement; return nextElement;
} }

Loading…
Cancel
Save