Skip to content

(feat): Autosave using localStorage #6864

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

Merged
merged 38 commits into from
May 20, 2025
Merged

(feat): Autosave using localStorage #6864

merged 38 commits into from
May 20, 2025

Conversation

dobri1408
Copy link
Contributor

@dobri1408 dobri1408 commented Mar 25, 2025


If your pull request closes an open issue, include the exact text below, immediately followed by the issue number. When your pull request gets merged, then that issue will close automatically.

Closes ##4168

PR preview:

https://volto--6864.org.readthedocs.build/6864/user-manual/blocks.html#autosave

Copy link

netlify bot commented Mar 25, 2025

Deploy Preview for plone-components canceled.

Name Link
🔨 Latest commit 67a1f04
🔍 Latest deploy log https://app.netlify.com/sites/plone-components/deploys/67e41a381eba940008b5b7ad

@dobri1408
Copy link
Contributor Author

I've updated the old pr #4252

Currently, the implementation works as follows:

  1. If you close the tab or click the cancel button, an autosaved copy is stored in localStorage.
  2. When you reopen the content, a toast notification informs you that a saved version is available, and you can choose to restore it.
  3. If someone else has edited the content in the meantime, the toast will let you know, and you can decide whether to load your local version.
  4. You can use the undo button to revert actions.
  5. This behavior applies both when creating new content and when editing existing content.

I think it would be useful to start a discussion around what additional features should be included in the final version.

@dobri1408
Copy link
Contributor Author

I've also included a video to remind you about the feature.

screen-capture.31.mp4

@dobri1408 dobri1408 moved this to Needs discussion in Volto Team Meeting Mar 25, 2025
@dobri1408 dobri1408 self-assigned this Mar 25, 2025
@dobri1408 dobri1408 added this to the 19.x.x milestone Mar 25, 2025
@stevepiercy
Copy link
Collaborator

Acceptance tests need to pass.

I think this is a great enhancement as is. I'd prefer to merge it after resolving failing tests. If and when we come to agreement on what additional features should be added, then we can enhance it further in separate PRs.

Copy link
Collaborator

@stevepiercy stevepiercy left a comment

Choose a reason for hiding this comment

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

I approve translation messages and change log.

It needs docs in the user manual, as a subsection in Edit content using blocks, "Autosave content". The change log, although terse, would be a good start. Screenshots or brief videos would be helpful.

It also needs a technical review from another member of @plone/volto-team.

Copy link
Collaborator

@stevepiercy stevepiercy left a comment

Choose a reason for hiding this comment

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

One final tweak on the docs (my bad), and they are good to go. I am crying tears of joy.

@dobri1408 dobri1408 requested a review from stevepiercy March 26, 2025 12:24
Copy link
Collaborator

@stevepiercy stevepiercy left a comment

Choose a reason for hiding this comment

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

Docs look good. Needs a technical review from @plone/volto-team

@github-project-automation github-project-automation bot moved this from Needs discussion to Work approved in Volto Team Meeting Mar 26, 2025
@stevepiercy stevepiercy requested review from a team March 26, 2025 12:55
@pnicolli
Copy link
Contributor

pnicolli commented Apr 8, 2025

I definitely want to discuss how to move this forward in the volto team meeting later today. One thing to keep in mind is: does this still work if the content type schema has changed since the last time it autosaved some data? In other words, it doesn't necessarily HAVE to work, but at least it should not break. I'm saying this as a reminder also for whoever will test this, as it hit me as a possible use case but I did not go through the code yet so maybe it's handled already, I don't know.

@pnicolli
Copy link
Contributor

pnicolli commented Apr 10, 2025

I am testing it but honestly can't make it work. Nothing seems to be written in my localstorage therefore no toast appears.

EDIT: scratch all this comment, I was working on an item that was broken in the backend. It's working now, I'll keep testing.

@pnicolli
Copy link
Contributor

First comment is: it's suggesting me to restore the autosaved data even if it's empty, would be great if it didn't, if at all possible.

To reproduce:

  1. add a page
  2. populate the title
  3. cancel and edit again
  4. apply autosaved data
  5. empty the title
  6. cancel and edit again
  7. it suggests autosaved data, if you apply it it's empty

@pnicolli
Copy link
Contributor

A couple other thoughts:

  1. it would probably be even better if we allowed users to clear autosaved data for a page in addition to just refusing to apply it, otherwise they will continue to show up until you actually save something
  2. should we consider having some cleanup mechanism to avoid cluttering the localStorage? I'm not even sure if this is the case, just wondering
  3. Every feature/idea I'm suggesting here and in previous comments can definitely become a separate issue if you want, instead of blocking this big PR even more. As I said in the Volto Team Meeting yesterday, this is the kind of PR that can become a mess if it sits here for a while.

I'll review the code shortly as well, the baseline feature is working fine for me when run locally.

Copy link
Contributor

@pnicolli pnicolli left a comment

Choose a reason for hiding this comment

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

Awesome, needs a little cleanup and then it's good to go

@dobri1408 dobri1408 requested a review from pnicolli May 14, 2025 07:27
Copy link
Member

@sneridagh sneridagh left a comment

Choose a reason for hiding this comment

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

LGTM!

I am not 100% sure about the messages still, but let's test drive it during the alpha, and improve on the go.

@sneridagh sneridagh merged commit 555dee6 into main May 20, 2025
63 checks passed
@sneridagh sneridagh deleted the auto-save branch May 20, 2025 06:56
@github-project-automation github-project-automation bot moved this from Work approved to Done in Volto Team Meeting May 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

4 participants