diff --git a/Filtration/ViewModels/ItemFilterScriptViewModel.cs b/Filtration/ViewModels/ItemFilterScriptViewModel.cs index 06e99e3..88428c5 100644 --- a/Filtration/ViewModels/ItemFilterScriptViewModel.cs +++ b/Filtration/ViewModels/ItemFilterScriptViewModel.cs @@ -1141,7 +1141,21 @@ namespace Filtration.ViewModels private void OnAddCommentBlockCommand() { - AddCommentBlock(SelectedBlockViewModel); + var selectedBlockAsCommentBlock = SelectedBlockViewModel as IItemFilterCommentBlockViewModel; + if (selectedBlockAsCommentBlock == null || selectedBlockAsCommentBlock.IsExpanded) + { + AddCommentBlock(SelectedBlockViewModel); + } + else + { + var sectionStart = ItemFilterBlockViewModels.IndexOf(selectedBlockAsCommentBlock); + var sectionEnd = sectionStart + 1; + while (sectionEnd < ItemFilterBlockViewModels.Count && ItemFilterBlockViewModels[sectionEnd] as IItemFilterCommentBlockViewModel == null) + { + sectionEnd++; + } + AddCommentBlock(ItemFilterBlockViewModels[sectionEnd - 1]); + } } private void OnExpandAllBlocksCommand()