-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Prevent page exit on the create page when there are unsaved changes #6566
Prevent page exit on the create page when there are unsaved changes #6566
Conversation
Welcome @avinashupadhya99! |
/assign @maciaszczykm |
I'd prefer to use a custom dialog that matches our UI design here. |
Is there an example I can look at? Thanks |
@floreks meant a dialog like the one that shows up when the namespace already exists. It's in the video. |
We'll need to prevent the page reload in the browser when the reload button is clicked and display the dialog and do a manual reload if necessary but it looks like we cannot prevent the reload. I tried out a simple experiement and as far as I know, there is no way to prevent the reload of a page without the browser confirmation dialog. I tried inserting dashboard/src/app/frontend/common/components/can-deactivate/component-can-deactivate.ts Line 26 in b125e66
$event.returnValue = true; but that did not prevent the page from reloading. Please correct me if I am wrong. I came across this SO answer which also states the same - https://stackoverflow.com/a/34415095.
|
I am not sure if you will be able to hijack and stop the browser refresh this way. I'd have to check to confirm. Will try to spend some time tomorrow on this. |
It is indeed not possible to hijack the dialog that appears before unloading the page. It's not even possible to update the text that is displayed there and it was an intentional change done by the browser devs to avoid malicious usage of such popups. I have refactored the code to match our style and used a custom dialog for the internal view change. The overall solution was good and I liked it. Thanks! |
Codecov Report
@@ Coverage Diff @@
## master #6566 +/- ##
=======================================
Coverage 42.55% 42.55%
=======================================
Files 217 217
Lines 10644 10644
Branches 177 177
=======================================
Hits 4530 4530
Misses 5851 5851
Partials 263 263 |
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: avinashupadhya99, floreks The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Closes #3567
Changes -
Included a short video explaining how the changes look like -
Kubernetes.Dashboard.changes.demo.mp4
Missed mentioning that there is no confirmation dialog if there are no changes to any of the forms or if the changes are reversed.