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

Inspector: should warn also when page is closed #3141

Closed
neos-bot opened this issue Oct 4, 2014 · 2 comments
Closed

Inspector: should warn also when page is closed #3141

neos-bot opened this issue Oct 4, 2014 · 2 comments

Comments

@neos-bot
Copy link

neos-bot commented Oct 4, 2014

Jira issue originally created by user @liwo:

The inspector should show a warning if the window is closed if there's still unsaved data.

Jira-URL: https://jira.neos.io/browse/NEOS-534

@mhsdesign mhsdesign transferred this issue from neos/neos-development-collection Jul 18, 2022
@mhsdesign
Copy link
Member

This would to the trick: (in combination with some checks if there are unsaved (unapplied) changed)

    public warnUserForPossibleNotSavedChanges(e: Event) {
        const confirmationMessage = `Es könnte sein, dass die letzten Änderungen noch nicht gespeichert sind.`;
        // @ts-expect-error
        (e || window.event).returnValue = confirmationMessage;
        return confirmationMessage;
    }

    public componentDidMount() {
        window.addEventListener(
            "beforeunload",
            this.warnUserForPossibleNotSavedChanges
        );
    }

    public componentWillUnmount() {
        window.removeEventListener(
            "beforeunload",
            this.warnUserForPossibleNotSavedChanges
        );
    }

@mhsdesign
Copy link
Member

duplicate of #2670 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants