-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Improve behaviour when saving content while offline #6322
Comments
In addition, clicking the |
Core ticket here, but not very relevant to Gutenberg: https://core.trac.wordpress.org/ticket/41535 |
It would indeed be a great improvement to show a warning when offline and to store the changes in In addition to this, I think we also now have the opportunity to go much father than having parity with the classic editor. With service workers we could provide an entirely offline authoring experience:
With this in place, if the user hits “Save Draft” when offline then a notice could appear as:
Enabling offline editing in Gutenberg is one of the key use cases we've identified for service workers in core for the PWA feature plugin. It would be great to identify what Gutenberg would need from service workers to enable offline usage so that the feature plugin can be built to facilitate it. |
Weston how you’d know which items to cache (posts, media) in preparation for the potential offline situation? |
@schmitzoide I'm guessing the heuristics would probably include caching the X most recently-modified posts, in addition to caching all of a user's drafts (and their media). It could then use runtime caching to store any other posts that the user accesses. The biggest challenge here I think is what to do in the conflict scenario, when you make changes to one version of a post offline but that post has had other changes done to it once you go back online. I suppose we'd need a merge conflict resolution UI. Another challenge for offline in WordPress is that some things would not be possible offline, including the uploading of new media and creation of new reusable blocks, since these would rely on obtaining new |
We could bypass the issues with conflicts by only doing background sync to push up changes to the user's autosave revision. That would then allow the user to restore the autosave which could then overwrite another user's changes. That's not great either as it just somewhat passes the buck, deferring the problem down the road. Instead of doing this the background sync could do a |
To me, this seems like a pretty big regression from the current editor. Why is it marked with Enhancement and not in the merge milestone? (unless the existing behavior, as noted/screenshotted in https://core.trac.wordpress.org/ticket/41535#comment:5 lives in a ticket I'm missing -- if so, my apologies) |
I have started tackling a lot of accessibility stuff for the merge and have let this sit a bit, but I would like to get back to it and have at least the beginnings of offline support for the merge. I originally committed to that but then ended up wrangling a lot of accessibility issues. It's still on my radar though… I agree I would like to see it in the merge. I guess I'll add it in for now; you can blame me if it doesn't make it! 😅 |
Cool, thanks so much! Appreciate the attempt either way. |
#7367 proposes saving post data to the REST API offline so data isn't lost, and I think that covers the first point. #4590 proposes better error messaging for the "Updating failed" error. If you agree the issues you've raised are covered in the other two, I would like to close this issue in favor of those in order to consolidate to more specific issues because it helps keep them actionable (and this issue/discussion can still be a good reference point for the others). If I've missed anything in my read of the suggestions that isn't covered by the other two issues, then we should keep this issue open. These are important issues and I also would like to say thank you for raising them! |
@designsimply I'm not sure if offline saving is entirely handled in #7367, but if so, it'd be great to have that back in the 5.0 milestone if this one is to be closed. In my opinion, it's a pretty big regression to lose offline saving, and the safety that comes from that when your connection is lost. |
Issues like these are certainly a tough call! #7367 does appear to need a dev that is not already dedicated elsewhere and that may not happen before 5.0. I'll leave this issue open just a bit longer as I agree offline saving is important but still want to get a check on whether we can consolidate these issues, even though #7367 slated for 5.1. |
I'll also note that at least one of the two (this one, or the two you mention) should probably be marked back-compat, rather than enhancement, as they are regressions in behavior. |
There's a work in progress in #9383 if anyone wants to help continue it (of note, |
I've opened a core ticket with patch for adding support for the |
Note: looking into this in terms of starting creating a small proof of concept based on Service Workers (see @westonruter's comment for specifics). |
Here's a PR (currently in full PoC state) for implementing very basic offline editing with Service Workers: It basically:
Other notes:
|
Closing this issue cause I believe offline save is implemented now cc @mcsf |
It's less ambitious than service workers, but local autosaves were added in #16490. |
Issue Overview
As Gutenberg is a JavaScript driven application that doesn't rely on traditional form submission like the current editor does, there's an opportunity to improve the end user experience when the client experiences connectivity problems or goes offline completely.
For example, if the saving action fails in any way, Gutenberg displays an error message that states
Updating failed
. It would be great if Gutenberg could inspect thenavigator.online
property at this point (or earlier), and if it returnsfalse
then display a more appropriate error message to the user, for exampleYou do not have an internet connection. Saving and previewing is not available offline
.A further enhancement would be to fully save the post content in the browser in the same way that the current editor does, to avoid data loss in case the user decides to close their browser window. This happens in the current editor, but not in Gutenberg. I'm not sure if there's an existing ticket for that.
The text was updated successfully, but these errors were encountered: