{"action":"created","issue":{"url":"https://api.github.com/repos/mobxjs/mobx-state-tree/issues/457","repository_url":"https://api.github.com/repos/mobxjs/mobx-state-tree","labels_url":"https://api.github.com/repos/mobxjs/mobx-state-tree/issues/457/labels{/name}","comments_url":"https://api.github.com/repos/mobxjs/mobx-state-tree/issues/457/comments","events_url":"https://api.github.com/repos/mobxjs/mobx-state-tree/issues/457/events","html_url":"https://github.com/mobxjs/mobx-state-tree/issues/457","id":264790152,"number":457,"title":"[Bug] middleware UndoManager","user":{"login":"builden","id":9499016,"avatar_url":"https://avatars1.githubusercontent.com/u/9499016?v=4","gravatar_id":"","url":"https://api.github.com/users/builden","html_url":"https://github.com/builden","followers_url":"https://api.github.com/users/builden/followers","following_url":"https://api.github.com/users/builden/following{/other_user}","gists_url":"https://api.github.com/users/builden/gists{/gist_id}","starred_url":"https://api.github.com/users/builden/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/builden/subscriptions","organizations_url":"https://api.github.com/users/builden/orgs","repos_url":"https://api.github.com/users/builden/repos","events_url":"https://api.github.com/users/builden/events{/privacy}","received_events_url":"https://api.github.com/users/builden/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2017-10-12T01:56:57Z","updated_at":"2017-12-22T14:43:38Z","closed_at":"2017-12-22T14:43:38Z","author_association":"NONE","body":"\"mobx-state-tree\": \"^1.0.1\"\r\n\r\n```js\r\nimport { types as t, onSnapshot } from 'mobx-state-tree';\r\nimport UndoManager from 'mobx-state-tree/middleware/UndoManager';\r\n\r\nconst initObj = {\r\n  obj: {\r\n    arr: [{ a: 1, b: 2 }],\r\n  },\r\n};\r\n\r\nconst Mutable = t.union(t.string, t.boolean, t.number, t.map(t.late(() => Mutable)), t.array(t.late(() => Mutable)));\r\nconst Store = t\r\n  .model('Store', {\r\n    frozen: Mutable,\r\n  })\r\n  .actions(self => ({\r\n    addProp(key, value) {\r\n      self.frozen.set(key, value);\r\n    },\r\n  }));\r\n\r\nconst store = Store.create({ frozen: initObj });\r\nconst undoMgr = UndoManager.create({}, { targetStore: store });\r\nstore.addProp('a', { c: ['x'] });\r\n```\r\n\r\nundoMgr.history.length = 3; // expect 1\r\n```json\r\n// undoMgr.history\r\n[\r\n  {\r\n    \"patches\": [],\r\n    \"inversePatches\": []\r\n  },\r\n  {\r\n    \"patches\": [],\r\n    \"inversePatches\": []\r\n  },\r\n  {\r\n    \"patches\": [\r\n      {\r\n        \"op\": \"add\",\r\n        \"path\": \"/frozen/a\",\r\n        \"value\": {\r\n          \"c\": [\r\n            \"x\"\r\n          ]\r\n        }\r\n      }\r\n    ],\r\n    \"inversePatches\": [\r\n      {\r\n        \"op\": \"remove\",\r\n        \"path\": \"/frozen/a\"\r\n      }\r\n    ]\r\n  }\r\n]\r\n```\r\n\r\nif I test, `store.addProp(b, 1)`, can get the right result, undoMgr.history.length = 1 "},"comment":{"url":"https://api.github.com/repos/mobxjs/mobx-state-tree/issues/comments/353611167","html_url":"https://github.com/mobxjs/mobx-state-tree/issues/457#issuecomment-353611167","issue_url":"https://api.github.com/repos/mobxjs/mobx-state-tree/issues/457","id":353611167,"user":{"login":"mweststrate","id":1820292,"avatar_url":"https://avatars0.githubusercontent.com/u/1820292?v=4","gravatar_id":"","url":"https://api.github.com/users/mweststrate","html_url":"https://github.com/mweststrate","followers_url":"https://api.github.com/users/mweststrate/followers","following_url":"https://api.github.com/users/mweststrate/following{/other_user}","gists_url":"https://api.github.com/users/mweststrate/gists{/gist_id}","starred_url":"https://api.github.com/users/mweststrate/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mweststrate/subscriptions","organizations_url":"https://api.github.com/users/mweststrate/orgs","repos_url":"https://api.github.com/users/mweststrate/repos","events_url":"https://api.github.com/users/mweststrate/events{/privacy}","received_events_url":"https://api.github.com/users/mweststrate/received_events","type":"User","site_admin":false},"created_at":"2017-12-22T14:43:38Z","updated_at":"2017-12-22T14:43:38Z","author_association":"OWNER","body":"Should be fixed in 1.3. Please reopen if it isn't the case"}}
{"actor":{"display_login":"mweststrate"}}