{"action":"closed","issue":{"url":"https://api.github.com/repos/aurelia/binding/issues/382","repository_url":"https://api.github.com/repos/aurelia/binding","labels_url":"https://api.github.com/repos/aurelia/binding/issues/382/labels{/name}","comments_url":"https://api.github.com/repos/aurelia/binding/issues/382/comments","events_url":"https://api.github.com/repos/aurelia/binding/issues/382/events","html_url":"https://github.com/aurelia/binding/issues/382","id":149530013,"number":382,"title":"View goes out of sync with model on select list options change","user":{"login":"istrau3","id":17746340,"avatar_url":"https://avatars.githubusercontent.com/u/17746340?v=3","gravatar_id":"","url":"https://api.github.com/users/istrau3","html_url":"https://github.com/istrau3","followers_url":"https://api.github.com/users/istrau3/followers","following_url":"https://api.github.com/users/istrau3/following{/other_user}","gists_url":"https://api.github.com/users/istrau3/gists{/gist_id}","starred_url":"https://api.github.com/users/istrau3/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/istrau3/subscriptions","organizations_url":"https://api.github.com/users/istrau3/orgs","repos_url":"https://api.github.com/users/istrau3/repos","events_url":"https://api.github.com/users/istrau3/events{/privacy}","received_events_url":"https://api.github.com/users/istrau3/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-04-19T17:37:06Z","updated_at":"2016-04-23T12:35:40Z","closed_at":"2016-04-23T12:35:40Z","body":"Please see the following reproduction:\r\nhttps://gist.run/?id=d933d929a37ec4bf4d0a1ffc89a8b586\r\n\r\nNote that initially 'bob' whose value is 1 is selected. The model (this.selected) is also equal to 1 (as seen after the button). After the \"Modify Options\" button is clicked, 'joe', whose value is 2, is selected but the model is still equal to 1. The model and view have gone out of sync.\r\n\r\nI don't think the view and the model should ever go out of sync. It seems in this case, after the options are switched out, the select list is maintaining its internal selectedIndex (and consequently switching the selected value that is displayed) but the aurelia model is not syncing to the new selected value.\r\n\r\nIdeally Aurelia would ensure that its model was persisted through the switch. So, in this case, if I had bob selected and then I switched the options, bob would still be selected but there would be other options to choose from (if bob was not available in the new list then the first options would be selected just like a new select list).\r\n\r\nThat said, I think if the select list's new selected value was bound up into the model after the options change that would still be a lot better than the current situation. Taking the above case again, if joe's value (2) was bound into the model after the options were switched out and the select list selected him (because it is maintaining the selectedIndex of 1), then I could replicate the ideal mechanism by manually reselecting bob (I would have to put some unecessary logic in my view model \r\n```javascript\r\nlet originalValue = this.selected;\r\nthis.options = newOptions;\r\nthis.taskQueue.queueTask(() => this.selected = originalValue);\r\n````\r\n). \r\n\r\nWith the current situation, even if I try something like the code above, it does nothing because selected already equals originalValue, it is out of sync with the view."}}