diff --git a/src/client/spark_core/Collections/Operable/Hierarchical/OperableHierarchicalCollection.cs b/src/client/spark_core/Collections/Operable/Hierarchical/OperableHierarchicalCollection.cs
index 27bdb176c..5a0f22db2 100644
--- a/src/client/spark_core/Collections/Operable/Hierarchical/OperableHierarchicalCollection.cs
+++ b/src/client/spark_core/Collections/Operable/Hierarchical/OperableHierarchicalCollection.cs
@@ -77,22 +77,26 @@ namespace bts.collections {
public void collapse_row(TKey key) {
_tree.collapse_row(key);
- _sync();
- /// Rather than calling , this optimization leverages the fact that the relative order of the rows has not changed, and the only mutation will be removing a single continuous block of rows.
- using (var en = _tree.rows.GetEnumerator()) {
- int pos = 0;
- while (en.MoveNext()) {
- if (!pos_matches()) {
- // found the beginning of the remove-block - remove each row until the keys match again
- do _remove_at(pos);
- while (!pos_matches());
+ if (_refresh.is_execution_deferred) {
+ // Do NOT attempt any optimizations (this collection was already out of sync with the tree).
+ _sync();
+ } else {
+ /// Rather than calling , this optimization leverages the fact that the relative order of the rows has not changed, and the only mutation will be removing a single continuous block of rows.
+ using (var en = _tree.rows.GetEnumerator()) {
+ int pos = 0;
+ while (en.MoveNext()) {
+ if (!pos_matches()) {
+ // found the beginning of the remove-block - remove each row until the keys match again
+ do _remove_at(pos);
+ while (!pos_matches());
+ }
+ pos++;
}
- pos++;
+ while (pos < Count)
+ _remove_at(pos);
+ bool pos_matches() =>
+ _key(this[pos].value).Equals(_key(en.Current.value));
}
- while (pos < Count)
- _remove_at(pos);
- bool pos_matches() =>
- _key(this[pos].value).Equals(_key(en.Current.value));
}
}