{"action":"created","issue":{"url":"https://api.github.com/repos/laravel-enso/FormBuilder/issues/52","repository_url":"https://api.github.com/repos/laravel-enso/FormBuilder","labels_url":"https://api.github.com/repos/laravel-enso/FormBuilder/issues/52/labels{/name}","comments_url":"https://api.github.com/repos/laravel-enso/FormBuilder/issues/52/comments","events_url":"https://api.github.com/repos/laravel-enso/FormBuilder/issues/52/events","html_url":"https://github.com/laravel-enso/FormBuilder/issues/52","id":381231838,"node_id":"MDU6SXNzdWUzODEyMzE4Mzg=","number":52,"title":"Warn when trying to navigate/leave with unsaved changes","user":{"login":"jlsjonas","id":932193,"node_id":"MDQ6VXNlcjkzMjE5Mw==","avatar_url":"https://avatars1.githubusercontent.com/u/932193?v=4","gravatar_id":"","url":"https://api.github.com/users/jlsjonas","html_url":"https://github.com/jlsjonas","followers_url":"https://api.github.com/users/jlsjonas/followers","following_url":"https://api.github.com/users/jlsjonas/following{/other_user}","gists_url":"https://api.github.com/users/jlsjonas/gists{/gist_id}","starred_url":"https://api.github.com/users/jlsjonas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jlsjonas/subscriptions","organizations_url":"https://api.github.com/users/jlsjonas/orgs","repos_url":"https://api.github.com/users/jlsjonas/repos","events_url":"https://api.github.com/users/jlsjonas/events{/privacy}","received_events_url":"https://api.github.com/users/jlsjonas/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":8,"created_at":"2018-11-15T16:10:25Z","updated_at":"2018-11-30T09:12:57Z","closed_at":null,"author_association":"CONTRIBUTOR","body":"<!-- Choose one of the following: -->\r\nThis is  a **feature request**.\r\n\r\n<!-- Make sure that everything is checked below: -->\r\n### Prerequisites\r\n* [x] Are you running the latest version?\r\n* [x] Are you reporting to the correct repository?\r\n* [x] Did you check the documentation?\r\n* [x] Did you perform a cursory search?\r\n\r\n### Description\r\n<!-- Description of the bug or feature -->\r\nAlert when trying to navigate away from the form with unsaved changes\r\n\r\n### Steps to Reproduce\r\n1. Edit any form\r\n2. Navigate away without clicking save\r\n\r\n### Expected behavior\r\n<!-- What you expected to happen -->\r\nWarning before leaving/closing the page losing changes\r\n\r\nNote: 2-sided: navigate within vue-router & navigating externally (i.e. page refresh and/or close)\r\n\r\n### Actual behavior\r\n<!-- What actually happened -->\r\nNavigating away, all changes are lost\r\n\r\n<!-- when the issue is resolved, don't forget to **CLOSE** it -->\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/laravel-enso/FormBuilder/issues/comments/443140035","html_url":"https://github.com/laravel-enso/FormBuilder/issues/52#issuecomment-443140035","issue_url":"https://api.github.com/repos/laravel-enso/FormBuilder/issues/52","id":443140035,"node_id":"MDEyOklzc3VlQ29tbWVudDQ0MzE0MDAzNQ==","user":{"login":"jlsjonas","id":932193,"node_id":"MDQ6VXNlcjkzMjE5Mw==","avatar_url":"https://avatars1.githubusercontent.com/u/932193?v=4","gravatar_id":"","url":"https://api.github.com/users/jlsjonas","html_url":"https://github.com/jlsjonas","followers_url":"https://api.github.com/users/jlsjonas/followers","following_url":"https://api.github.com/users/jlsjonas/following{/other_user}","gists_url":"https://api.github.com/users/jlsjonas/gists{/gist_id}","starred_url":"https://api.github.com/users/jlsjonas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jlsjonas/subscriptions","organizations_url":"https://api.github.com/users/jlsjonas/orgs","repos_url":"https://api.github.com/users/jlsjonas/repos","events_url":"https://api.github.com/users/jlsjonas/events{/privacy}","received_events_url":"https://api.github.com/users/jlsjonas/received_events","type":"User","site_admin":false},"created_at":"2018-11-30T09:12:57Z","updated_at":"2018-11-30T09:12:57Z","author_association":"CONTRIBUTOR","body":"I suppose it lies somewhere in between...\r\nI think the handling is rather something _global_; and although the above implementation only affects vueform, any other form-like element that sets the preventUnload will also prevent unloading\r\n\r\nexample _global_ use case: non-VueForm based flow that is usually expected to be completed before navigating away, could re-use the state & globally defined unload handlers\r\n\r\nsidenote: while doing more testing I discovered the current `onbeforeunload` (window, not vue-router) method used above didn't always work. instead I've modified the mutation to ALSO set `window.preventUnload` and modified the `window.onbeforeunload = ...` to:\r\n```js\r\n\r\n            window.addEventListener('beforeunload', function (e) {\r\n                if(window.preventUnload) {\r\n                    e.preventDefault();\r\n                    e.returnValue = '';\r\n                }\r\n            });\r\n```\r\n(I still believe it should be kept in state/using a mutation so you can properly see changes in debugging tools)"}}
{"actor":{"display_login":"jlsjonas"}}