Replies: 10 comments 12 replies
-
Thanks for starting this discussion! I've been thinking a bit about how we could implement autosave recently, here are my thoughts on what we could implement to support a basic (non-collaboration) autosave in Wagtail Save draft without page reloadCurrently, Wagtail reloads the page on every save. Before implementing autosave, we'll need to change it to save in the background instead. This requires the following:
This on its own would actually give us a nice UX improvement as the browser will no longer scroll back to the top of the page on save making it easier to work on larger pages. All other options such as “Publish” and “Submit to workflow” should continue to reload the page. AutosaveAfter saving without reload is supported, we can start getting Wagtail to trigger save draft automatically in the background, and remove the "Save draft" button. Things that can trigger save draft:
RevisionsTo avoid bloating up the database with lots of revisions which can make page history really hard to manage, we need to rethink how revisions are created for autosave. One approach to this could be to create a revision on the first edit of a session* and update that revision on subsequent edits. *Where a session starts when the user opens the page editor, and finishes when they navigate away. Note: We will need to change the revision behaviour again later on when we start allowing multiple editors to edit a page at the same time. For now, we would need to implement automatic page locking to prevent editors from overwriting each other Creating new pagesThe create page view should work the same way it does today:
Invalid dataIf the page is edited in any way that makes the data invalid, the validation errors will be displayed to the user immediately and auto-save will stop saving the page until the error is corrected. Automatic page lockingAt this stage, autosave will not be able to handle more than one user at a time. So to prevent them from accidentally overwriting each other, we will implement automatic locking in the page editor. This should be separate from the existing manual locking feature. The first user to visit the page editor will not notice any difference and be able to edit normally. If another user tries to edit the page before that first editor has left, the fields will all be locked. The page would be automatically unlocked when:
When the page unlocks, it will automatically reload for any other users who are viewing the locked editor. This is to make sure that the user who acquires the lock is on the latest version of the page.
If the user who has the lock doesn’t edit the page for more than 30 minutes, the page would be unlocked and the fields would become locked for that user. |
Beta Was this translation helpful? Give feedback.
-
There is a practical reason for keeping the Save Draft button, not just 'peace of mind' - it will ensure that a persistent revision gets saved at that point (one that doesn't get overwritten on subsequent auto-saves), allowing the possibility of rolling back to it. |
Beta Was this translation helpful? Give feedback.
-
FYI we’ve further discussed this internally – pondering how much behind-the-scenes changes would be needed, and what the experience looks like for end users beyond the simple "success path" that’s easy to cater for. We’ll likely provide more substantive updates in the near future. If others have good examples of systems that do this well currently, please share, keeping in mind a lot of the UI considerations we need to make are around data validation (e.g. required fields), so things like Google Docs which we all love but don’t have such a concept aren’t as relevant. |
Beta Was this translation helpful? Give feedback.
-
Two big questions we've been thinking about with Milestone 1 (which is where we're likely to be aiming initially (unsurprisingly)). 1. When creating a page, at what point do we start autosaving.
2. At milestone 1, although the page is autosaving in the background, we are unable to show changes made by others in real time. How do we prevent people from consistently overwriting each other's changes.
|
Beta Was this translation helpful? Give feedback.
-
We need to be careful to correctly handle the case where a user has multiple tabs open editing the same page - if they edit, save, then go back to a tab containing an older version of the content and edit any field, this will trigger an autosave that replaces the latest revision by that same user - at minimum, we need to make sure that happens as a new revision, not an db update on that latest revision. |
Beta Was this translation helpful? Give feedback.
-
I think this has come up earlier in this discussion, but I just would like to emphasize that it would be extremely useful to have a field be required only on publishing, but not when saving a draft of a page. There are so many occasions I've seen where one would want to start drafting a page before certain required content is ready. |
Beta Was this translation helpful? Give feedback.
-
For people following this discussion - a few recent updates:
We’ve been discussing UI frameworks for Wagtail in #7689 (comment) and as part of the page editor work. There is some overlap between those discussions (cc @lb- @kaedroho @mixxorz) and auto-save / collaboration features – as soon as we start syncing page updates from multiple users and reflecting other users’ updates in the browser, we’d need some form of dynamic form re-rendering, which doesn’t fit well with Django’s vanilla forms rendering. For the page editor 2022 project’s variant of auto-save, we’re not expecting any significant re-architecture, but in the future we expect this might be needed. There are a few important considerations here:
Short term, we’ve also been wondering how auto-save interacts with bespoke Django widgets:
|
Beta Was this translation helpful? Give feedback.
-
For people interested in this – here’s a recent update in @phildexter’s page editor build update blog post. We’re currently looking for funding to support the wider rework of the page editor, and this is one of the features that will be de-scoped if we don’t find this funding. Here is the UI we’ve designed so far for reference – a top-level "auto-save indicator". Then form fields’ errors would appear similarly to they do now (just as you go through the page rather than on publish/save draft). And "Save draft" would obviously be gone – we’d only retain an option to name specific "auto-saved" versions. Additionally we would have a dialog to help with potential conflicts, if multiple editing sessions are attempting to auto-save a page in a way that would create conflicts: |
Beta Was this translation helpful? Give feedback.
-
Are there any updates on this? |
Beta Was this translation helpful? Give feedback.
-
I have used this fork of Django Admin locking in my projects and been happy with the results. https://github.com/theatlantic/django-admin-locking The features match the description @kaedroho wrote for automatic page locking, and may be of some use for reference despite not receiving regular development. |
Beta Was this translation helpful? Give feedback.
-
I saw that #3527 is still open, but no update so far.
In the issue, it is mentioned that auto-saving revision could lead to a massive amount of revision.
I also remember discussing this in slack and there are other issues like required field that are missing.
As an additional note, I have notified the users to save often, but in the end, we can't really control what the user do, sometimes they don't want to break their writing/editing flow.
Idea 1: localStorage and storing it in browser.
I am not an expert on this and not sure localStorage is a viable option for storing the current state of the edit page. There must be some kind of problem of using this method? The idea is to "save" the content of the edit page (let's call it "recovery") into LocalStorage every X minute (Overwrite the previous recovery instead having a new recovery every time). Also, when the user actually click Save Draft/Publish button, the localStorage should be cleared? or should it be cleared upon publish only?.
Idea 2: Having a "recovery" table in the database
If say the computer crashes and the user needs to grab the "recovery" on another computer. With this, I am not sure if it will interrupt/refreshes the page upon every auto-save. I am also not sure how this will affect the performance of the database too.
Just writing out what I have in mind, I also saw that there's django-autosave, and that there's something about using Django Channels? (I haven't looked further into both yet)
Has anyone out there tried out/come up with an auto-save solution that works?
Beta Was this translation helpful? Give feedback.
All reactions