Skip to content

Commit

Permalink
Merge pull request #665 from SMI/feature/fix-selected-obj-after-remove
Browse files Browse the repository at this point in the history
fixed index preservation after node removals in is identifiable reviewer
  • Loading branch information
tznind authored Mar 12, 2021
2 parents ca76f34 + 412d240 commit 934c82e
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
1 change: 1 addition & 0 deletions news/665-bugfix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixed tree view loosing selected index when updating/ignoring a failure (in tree view)
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,31 @@ private void Ignore(OutstandingFailureNode ofn, bool isBulkIgnore)
/// <param name="obj"></param>
private void Remove(ITreeNode obj)
{
_treeView.GetParent(obj)?.Children?.Remove(obj);
_treeView.RefreshObject(obj,true);
var siblings = _treeView.GetParent(obj)?.Children;

if(siblings == null)
{
return;
}

var idxToRemove = siblings.IndexOf(obj);

if(idxToRemove == -1)
{
return;
}


// remove us
siblings.Remove(obj);

// but preserve the selected index
if (idxToRemove < siblings.Count)
{
_treeView.SelectedObject = siblings[idxToRemove];
}

_treeView.RefreshObject(obj, true);
}


Expand Down

0 comments on commit 934c82e

Please sign in to comment.