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

SubLanguage plugin keeps the Gutenberg editor in a permanently "dirty" state (browser warns of "unsaved changes" even if there are none #62

Open
nekohayo opened this issue Feb 13, 2022 · 3 comments

Comments

@nekohayo
Copy link

This is basically the same thing as WordPress/gutenberg#17395 and WordPress/gutenberg#24679, and I was wondering why I kept encountering the issue on my personal blog, where Firefox (tested on version 94, but it happened with any version, for years) would always warn me like this when I try to navigate away from the blog post editor, even if I just clicked the "Save draft" (or "Update post") button 2 seconds ago, or even if I enter an already published post and do not touch anything before trying to exit it:

Screenshot from 2022-02-13 11-43-54

To reproduce, with the SubLanguage plugin active:

  1. Enter editing mode for a blog post
  2. Wait for the Gutenberg editor to fully load
  3. Click the "W" wordpress logo on the top left to try to exit the editor and to go back to the posts list
@maximeschoeni
Copy link
Owner

Hello, thanks for reporting.
This is appening because sublanguage is running a script that periodically set a variable corresponding to the language being edited. As Gutenberg synchronize this variable after every save, it needs to be constantly set by a timer function. This is causing the editor to be permanently dirty. A much better alternative would be to run a function to set this variable once just before Gutenberg saves stuffs, but as stupid as it may sounds, I still did not find out how to do that :(

@nekohayo
Copy link
Author

Maybe you could git grep gutenberg's code to find out the saving-related code, see what happens in there, if maybe it fires off a signal/event/something that you could connect to? Just wildly guessing, I have no idea how any of this works :)

@nekohayo
Copy link
Author

Actually, maybe function PostSavedState is where it's happening at. Again, just guessing, purely by luck from the fact that I happened to be looking at the diff in WordPress/gutenberg#38776

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

No branches or pull requests

2 participants