Undo fails at reverting additions to a store object
When using a store with objects and adding new key value pairs, undo (and probably redo) don’t quite work. Oddly enough it works fine if it is used with object signals
Example to reproduce:
const [data, setData, history] = record(createStore({}));
setData({ hello: true }) // This will be pushed to record history
history.undo() // This will move the undo index backwards but not revert the last setData
return <h1>{data.hello.toString()}</h1> // true
Nested objects in a store also fail. Probably something to do with how store objects are proxies?
Nested objects in a signals work fine so that might be it.
Hey @ThaisRobba, thanks for reporting!
The issue is that solidjs shallowly merges object properties when you provide an object to a store setter. So basically in your example undoing the change would be the same as simply calling setStore({}), which wouldn't do anything either since {} would be merged with { hello: true }. Simply wrapping the object in reconcile() should resolve the issue.
I will fix this asap, thanks again!