Skip to content
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

Implement warning for unsaved changes in dashboard #145

Closed
jspenguin2017 opened this issue Jul 25, 2018 · 7 comments
Closed

Implement warning for unsaved changes in dashboard #145

jspenguin2017 opened this issue Jul 25, 2018 · 7 comments
Labels
enhancement New feature or request question query or an enquiry

Comments

@jspenguin2017
Copy link

I want to help fixing gorhill/uBlock#3271

Since the dashboard is driven by iframes, I think one way to implement it is to make each iframe to expose a global variable, hasUnsavedChanges. When the dashboard is closing or the tab is changing, the main frame will check the global variable of the child frame and show a warning message if needed.

@gorhill Do you think this is a good way to implement it? Do you want me to PR?

@uBlock-user uBlock-user added enhancement New feature or request question query or an enquiry labels Jul 25, 2018
@gorhill
Copy link
Member

gorhill commented Jul 25, 2018

Do you think this is a good way to implement it? Do you want me to PR?

Sounds fine to me, I would accept a PR, thanks. I haven't thought much about this, not sure how the warning should be designed (I feel DOM-based would be better).

@gwarser
Copy link

gwarser commented Jul 25, 2018

When the dashboard is closing

nothing can be done... ?

https://developer.mozilla.org/en-US/docs/Web/Events/beforeunload#Notes

@gorhill
Copy link
Member

gorhill commented Jul 25, 2018

The dashboard code is the one swapping panes, so it's just a matter of having a warning when a pane is detected as having unsaved changes, and waiting for confirmation before swapping. If the only case left is the closing of the whole dashboard itself, it's not too bad.

@jspenguin2017
Copy link
Author

jspenguin2017 commented Jul 25, 2018

I feel DOM-based would be better

The warning for dashboard closing will always be a confirm-like dialog. So I was thinking of mimicking that, but it's hard to get the prompt text to be consistent though.

@jspenguin2017
Copy link
Author

jspenguin2017 commented Jul 26, 2018

I have some problem with uDom. It tears everything down when beforeunload event is fired... Eh, why?

// Cleanup

var onBeforeUnload = function() {
    var entry;
    while ( (entry = listenerEntries.pop()) ) {
        entry.dispose();
    }
    window.removeEventListener('beforeunload', onBeforeUnload);
};

window.addEventListener('beforeunload', onBeforeUnload);

@jspenguin2017
Copy link
Author

image
image

@jspenguin2017
Copy link
Author

I'll close this in favor of the PR, where we can review the changes easily.

@uBlock-user uBlock-user changed the title [PR Question] Implement warning for unsaved changes in dashboard Implement warning for unsaved changes in dashboard Jul 26, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request question query or an enquiry
Projects
None yet
Development

No branches or pull requests

4 participants