{"action":"created","issue":{"url":"https://api.github.com/repos/orbeon/orbeon-forms/issues/2318","labels_url":"https://api.github.com/repos/orbeon/orbeon-forms/issues/2318/labels{/name}","comments_url":"https://api.github.com/repos/orbeon/orbeon-forms/issues/2318/comments","events_url":"https://api.github.com/repos/orbeon/orbeon-forms/issues/2318/events","html_url":"https://github.com/orbeon/orbeon-forms/issues/2318","id":95697447,"number":2318,"title":"xf:upload with label fails second time","user":{"login":"ebruchez","id":105769,"avatar_url":"https://avatars.githubusercontent.com/u/105769?v=3","gravatar_id":"","url":"https://api.github.com/users/ebruchez","html_url":"https://github.com/ebruchez","followers_url":"https://api.github.com/users/ebruchez/followers","following_url":"https://api.github.com/users/ebruchez/following{/other_user}","gists_url":"https://api.github.com/users/ebruchez/gists{/gist_id}","starred_url":"https://api.github.com/users/ebruchez/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ebruchez/subscriptions","organizations_url":"https://api.github.com/users/ebruchez/orgs","repos_url":"https://api.github.com/users/ebruchez/repos","events_url":"https://api.github.com/users/ebruchez/events{/privacy}","received_events_url":"https://api.github.com/users/ebruchez/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/orbeon/orbeon-forms/labels/XForms","name":"XForms","color":"ededed"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-07-17T16:52:02Z","updated_at":"2015-07-17T18:35:09Z","closed_at":null,"body":"- <xf:upload> with label\r\n- upload file\r\n- click label\r\n- this opens (on Chrome at least) file chooser again\r\n- file uploads\r\n- but control is messed up, see screenshot\r\n\r\n![upload](https://cloud.githubusercontent.com/assets/105769/8752533/757acd3e-2c69-11e5-870b-ff52ed9c544a.png)\r\n"},"comment":{"url":"https://api.github.com/repos/orbeon/orbeon-forms/issues/comments/122368392","html_url":"https://github.com/orbeon/orbeon-forms/issues/2318#issuecomment-122368392","issue_url":"https://api.github.com/repos/orbeon/orbeon-forms/issues/2318","id":122368392,"user":{"login":"ebruchez","id":105769,"avatar_url":"https://avatars.githubusercontent.com/u/105769?v=3","gravatar_id":"","url":"https://api.github.com/users/ebruchez","html_url":"https://github.com/ebruchez","followers_url":"https://api.github.com/users/ebruchez/followers","following_url":"https://api.github.com/users/ebruchez/following{/other_user}","gists_url":"https://api.github.com/users/ebruchez/gists{/gist_id}","starred_url":"https://api.github.com/users/ebruchez/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ebruchez/subscriptions","organizations_url":"https://api.github.com/users/ebruchez/orgs","repos_url":"https://api.github.com/users/ebruchez/repos","events_url":"https://api.github.com/users/ebruchez/events{/privacy}","received_events_url":"https://api.github.com/users/ebruchez/received_events","type":"User","site_admin":false},"created_at":"2015-07-17T18:35:09Z","updated_at":"2015-07-17T18:35:09Z","body":"Reproducible with:\r\n\r\n```xml\r\n<xf:upload ref=\".\">\r\n    <xf:label>Upload!</xf:label>\r\n</xf:upload>\r\n```\r\n\r\nIssue is in `Upload.coffee`'s `uploadDone`:\r\n\r\n- 1st upload completes\r\n    - `UploadServer.uploadSuccess`\r\n    - `UploadServer.continueWithRemainingEvents`\r\n    - `Upload.uploadDone` adds listener\r\n- 1st Ajax response arrives\r\n    - happens to be\r\n    ```xml\r\n    <xxf:event-response xmlns:xxf=\"http://orbeon.org/oxf/xml/xforms\">\r\n        <xxf:action>\r\n            <xxf:control-values>\r\n                <xxf:control \r\n                    id=\"xf-4\" \r\n                    visited=\"true\" \r\n                    progress-expected=\"34700\" \r\n                    progress-state=\"completed\"\r\n                    progress-received=\"34385\"/>\r\n            </xxf:control-values>\r\n        </xxf:action>\r\n    </xxf:event-response>\r\n    ```\r\n    - so `@setState \"empty\"` is called\r\n- 2nd Ajax response arrives\r\n    - happens to be\r\n    ```xml\r\n    <xxf:event-response xmlns:xxf=\"http://orbeon.org/oxf/xml/xforms\">\r\n        <xxf:action>\r\n            <xxf:control-values>\r\n                <xxf:control \r\n                    id=\"xf-4\" progress-expected=\"\" \r\n                    state=\"file\" \r\n                    progress-state=\"\" \r\n                    filename=\"test1.jpg\"\r\n                    progress-received=\"\"/>\r\n            </xxf:control-values>\r\n        </xxf:action>\r\n    </xxf:event-response>\r\n    ```\r\n- seems good so far\r\n- except comment \"After the file is uploaded, in general at the next Ajax response, we get the file name\" is wrong\r\n- 2nd upload completes\r\n    - `Upload.uploadDone` adds listener\r\n- 1st Ajax response arrives but has no actions (luck, or bug?)\r\n    - so `@setState \"empty\"` is called\r\n- 2nd Ajax response arrives\r\n    - has `filename=\"test2.jpg\"` but might not have a difference\r\n    - because server went from `state=\"file\"` to `state=\"file\"`, it doesn't send `state=\"file\"` again\r\n    - so upload remains in `empty` state with `xforms-upload-state-empty`\r\n\r\nWhy this listener to set the state to `empty`? Shouldn't the server tell the client to switch state?"}}