@@ -211,9 +211,16 @@ listWithKey :: forall t k v m a. (Ord k, DomBuilder t m, PostBuild t m, MonadFix
211211listWithKey vals mkChild = do
212212 postBuild <- getPostBuild
213213 let childValChangedSelector = fanMap $ updated vals
214+ -- We keep track of changes to children values in the mkChild function we pass to listHoldWithKey
215+ -- The other changes we need to keep track of are child insertions and deletions. diffOnlyKeyChanges
216+ -- keeps track of insertions and deletions but ignores value changes, since they're already accounted for.
217+ diffOnlyKeyChanges olds news = flip Map.mapMaybe (align olds news) $ \case
218+ This _ -> Just Nothing
219+ These _ _ -> Nothing
220+ That new -> Just $ Just new
214221 rec sentVals :: Dynamic t (Map k v) <- foldDyn applyMap Map.empty changeVals
215222 let changeVals :: Event t (Map k (Maybe v))
216− changeVals = attachWith diffMapNoEq (current sentVals) $ leftmost
223+ changeVals = attachWith diffOnlyKeyChanges (current sentVals) $ leftmost
217224 [ updated vals
218225 , tag (current vals) postBuild --TODO: This should probably be added to the attachWith, not to the updated; if we were using diffMap instead of diffMapNoEq, I think it might not work
219226 ]