fix: track parents when tracking keyed subfield (second half of #4475)

This commit is contained in:
Greg Johnston
2025-12-26 12:13:45 -05:00
parent 81cff63455
commit 2f2b5ac7b5

View File

@@ -140,13 +140,20 @@ where
}
fn track_field(&self) {
let inner = self
.inner
.get_trigger(self.inner.path().into_iter().collect());
inner.this.track();
let mut full_path = self.path().into_iter().collect::<StorePath>();
let trigger = self.get_trigger(self.path().into_iter().collect());
trigger.this.track();
trigger.children.track();
// tracks `this` for all ancestors: i.e., it will track any change that is made
// directly to one of its ancestors, but not a change made to a *child* of an ancestor
// (which would end up with every subfield tracking its own siblings, because they are
// children of its parent)
while !full_path.is_empty() {
full_path.pop();
let inner = self.get_trigger(full_path.clone());
inner.this.track();
}
}
}