From e65969cfcd1524b2ad3dc1d62f40c4d10fbd224e Mon Sep 17 00:00:00 2001 From: Greg Johnston Date: Wed, 11 Dec 2024 20:03:41 -0500 Subject: [PATCH] fix: nested keyed fields in stores (closes #3338) (#3344) --- reactive_stores/src/keyed.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/reactive_stores/src/keyed.rs b/reactive_stores/src/keyed.rs index aa40130fe7..4d9a4273f2 100644 --- a/reactive_stores/src/keyed.rs +++ b/reactive_stores/src/keyed.rs @@ -623,10 +623,15 @@ where .keys() .expect("updating keys on a store with no keys"); + // generating the latest keys out here means that if we have + // nested keyed fields, the second field will not try to take a + // read-lock on the key map to get the field while the first field + // is still holding the write-lock in the closure below + let latest = self.latest_keys(); keys.with_field_keys( inner_path, |keys| { - keys.update(self.latest_keys()); + keys.update(latest); }, || self.latest_keys(), );