Fix adding block to a collapsed section

This commit is contained in:
azakhi 2018-08-12 11:39:36 +03:00
parent 216168533f
commit 5817295f7c
1 changed files with 15 additions and 1 deletions

View File

@ -1037,7 +1037,21 @@ namespace Filtration.ViewModels
private void OnAddBlockCommand() private void OnAddBlockCommand()
{ {
AddBlock(SelectedBlockViewModel); var selectedBlockAsCommentBlock = SelectedBlockViewModel as IItemFilterCommentBlockViewModel;
if(selectedBlockAsCommentBlock == null || selectedBlockAsCommentBlock.IsExpanded)
{
AddBlock(SelectedBlockViewModel);
}
else
{
var sectionStart = ItemFilterBlockViewModels.IndexOf(selectedBlockAsCommentBlock);
var sectionEnd = sectionStart + 1;
while (sectionEnd < ItemFilterBlockViewModels.Count && ItemFilterBlockViewModels[sectionEnd] as IItemFilterCommentBlockViewModel == null)
{
sectionEnd++;
}
AddBlock(ItemFilterBlockViewModels[sectionEnd - 1]);
}
} }
public void AddBlock(IItemFilterBlockViewModelBase targetBlockViewModelBase) public void AddBlock(IItemFilterBlockViewModelBase targetBlockViewModelBase)