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 Alert Feature for Unsaved Changes in Editor #79

Merged
merged 3 commits into from
Oct 7, 2024

Conversation

mSaurabh
Copy link

@mSaurabh mSaurabh commented Oct 6, 2024

This pull request implements the "Better Save" feature (issue #11) by introducing an alert mechanism that warns users of unsaved changes when attempting to leave the screen without saving their content. The changes are contained within the editor.js file.

Changes:
Added a new alert feature that triggers when the user attempts to navigate away from the editor screen without saving their changes.
Implemented a check to detect unsaved changes and display a confirmation prompt to the user.

Related Issues:
Closes #11: Better Save feature implementation

Notes:
This implementation uses a flag called prevent_save and function checkForUnsavedChanges to check for unsaved changes. Also added a beforeunload event listener to make changes to prevent_save flag based on user choice.

@mSaurabh mSaurabh mentioned this pull request Oct 6, 2024
@@ -37,16 +41,19 @@ async function start_editor() {

} else {
status_error();
log("WARNING", "There was a problem")
create_notification("There was a problem", "There was an unknown issue", "warning");
log("WARNING", "There was a problem");
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Formatter being naughty. 😅

@nfoert
Copy link
Owner

nfoert commented Oct 6, 2024

Hey @mSaurabh, thanks for working on this! I attempted to test out the new feature but it appears that most of the static files couldn't be loaded anymore
image

The resource from “http://127.0.0.1:8000/static/main/ui.css” was blocked due to MIME type (“text/html”) mismatch (X-Content-Type-Options: nosniff). 127.0.0.1:8000
The resource from “http://127.0.0.1:8000/static/main/footer.css” was blocked due to MIME type (“text/html”) mismatch (X-Content-Type-Options: nosniff). 127.0.0.1:8000
The resource from “http://127.0.0.1:8000/static/main/scripts/global/favicon.js” was blocked due to MIME type (“text/html”) mismatch (X-Content-Type-Options: nosniff). 127.0.0.1:8000
--snip--

Is this happening for you too or is this just some kind of error on my side? I'm not sure why this is occurring as you've not committed to anything besides editor.js

@nfoert nfoert added the hacktoberfest A good issue for hacktoberfest 2024 label Oct 6, 2024
@mSaurabh
Copy link
Author

mSaurabh commented Oct 7, 2024

I think ar4s added some ruff changes that I pulled from master branch before creating my PR that might be causing these errors @nfoert

@nfoert
Copy link
Owner

nfoert commented Oct 7, 2024

I think ar4s added some ruff changes that I pulled from master branch before creating my PR that might be causing these errors

It turns out I had forgotten to create the .env file which was causing some strange behaviors, that was my bad

I also added a simple indicator to show if there's been any unsaved changes as I think that would be a good visual cue to the user
image

I'll get this merged now, thanks again!

@nfoert nfoert merged commit efc2f64 into nfoert:development Oct 7, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hacktoberfest A good issue for hacktoberfest 2024
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants