{"action":"opened","issue":{"url":"https://api.github.com/repos/elm/virtual-dom/issues/149","repository_url":"https://api.github.com/repos/elm/virtual-dom","labels_url":"https://api.github.com/repos/elm/virtual-dom/issues/149/labels{/name}","comments_url":"https://api.github.com/repos/elm/virtual-dom/issues/149/comments","events_url":"https://api.github.com/repos/elm/virtual-dom/issues/149/events","html_url":"https://github.com/elm/virtual-dom/issues/149","id":386301045,"node_id":"MDU6SXNzdWUzODYzMDEwNDU=","number":149,"title":"Checkbox \"checked\" value un-toggled before event handler is triggered","user":{"login":"terezka","id":5760625,"node_id":"MDQ6VXNlcjU3NjA2MjU=","avatar_url":"https://avatars3.githubusercontent.com/u/5760625?v=4","gravatar_id":"","url":"https://api.github.com/users/terezka","html_url":"https://github.com/terezka","followers_url":"https://api.github.com/users/terezka/followers","following_url":"https://api.github.com/users/terezka/following{/other_user}","gists_url":"https://api.github.com/users/terezka/gists{/gist_id}","starred_url":"https://api.github.com/users/terezka/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/terezka/subscriptions","organizations_url":"https://api.github.com/users/terezka/orgs","repos_url":"https://api.github.com/users/terezka/repos","events_url":"https://api.github.com/users/terezka/events{/privacy}","received_events_url":"https://api.github.com/users/terezka/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-11-30T18:31:53Z","updated_at":"2018-11-30T18:31:53Z","closed_at":null,"author_association":"NONE","body":"If you have the following code:\r\n\r\n```elm\r\nHtml.div\r\n   [ Events.stopPropagationOn  \"click\" (Json.Decode.succeed ( NoOp, True )) ]\r\n   [ Html.input\r\n      [ Events.type_ \"checkbox\"\r\n      , Events.onCheck Toggle\r\n      , Events.checked model.isChecked\r\n      ]\r\n      []\r\n   ]\r\n```\r\n\r\nthe checkbox will not toggle. \r\n\r\nThe interesting part is that if you remove the `checked model.on`, it works again. The theory is that `NoOp` gets triggered (synchronously), re-renders the DOM, overwriting the newly `checked` value, before the `Toggle` event handler is triggered. Because `Toggle` uses the `checked` value for the boolean it sends with the message, it sends the wrong boolean, since the `checked` value was flipped back by the `NoOp` render.\r\n\r\nA possible work around just to ignored the `checked` value from `onCheck` and just toggle your model directly.\r\n\r\n```elm\r\nEvents.onCheck (\\_ -> Toggle (not model.isChecked))\r\n```\r\n"}}
{"actor":{"display_login":"terezka"}}