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

Discard Draft does not delete draft #3927

Closed
ThaMunsta opened this issue Dec 20, 2022 · 3 comments
Closed

Discard Draft does not delete draft #3927

ThaMunsta opened this issue Dec 20, 2022 · 3 comments

Comments

@ThaMunsta
Copy link

Describe the Bug

A saved draft is not removed from the database by clicking Discard Draft at the top of the page.

Steps to Reproduce

  1. Create a new page (or edit an existing)
  2. Type some changes
  3. Save your draft using the link at the top of the edit page
  4. Discard your draft using the link at the top of the edit page
  5. Refresh the browser window (or open the MySQL database)
  6. You are now editing the same draft from earlier (or find the draft still in the MySQL database)

Expected Behaviour

The button named Discard Draft should remove the stored changes from the database so a user doesn't go in to edit the page later and save edits from an old draft that were not intended to be "remembered". Ideally this will also prevent the warning about unsaved changes when you are navigating away from the page.

Screenshots or Additional Context

The two buttons in question are at the top of the page and look like this:
image

Browser Details

Chrome Version 108.0.5359.125 on Windows 10 21H2

Exact BookStack Version

v22.11.1

PHP Version

PHP 8.0.25

Hosting Environment

Docker Image (linuxserver/bookstack:latest) hosted behind Nginx Proxy Manager.
Reproduced on https://demo.bookstackapp.com/ logged in as admin.
Originally discovered on older version (v21 something I believe) but looking at the docs and page-editor.js it might have been this way for a while. If it was intentional - my apologies.

@ssddanbrown
Copy link
Member

Thanks for the clear report @ThaMunsta.

The "Discard Draft" button has always just discarded the draft content (Re-fetches current saved page content) from the editor, and not touched the database, but I can see how this is not clear by the action name, and with it being alongside the "Save Draft" button which is a database action. Also can understand why you'd want to be able to actually delete the draft.

Maybe we need to provide two options:

  • A "Discard Draft" button that actually deletes from the database.
  • A "Restore Non-Draft Content" button that does the current behaviour.

Ideally would want more concise wording for that second option.


Maintainer Note

  • Would need show an update advisory if we do the above since it changes the behaviour of the "Discord Draft" button while having the same name.

@ThaMunsta
Copy link
Author

I'll throw my name suggestion in the hat:

  • A "Delete Draft" button that actually deletes from the database. Everyone knows what delete means.
  • A "Discard Changes" button that does the current behaviour. Or more verbose: "Discard Current Changes"

I think especially displayed in that order, it will be easy to understand what the second button does.

Thanks for taking the time to read this!

@ssddanbrown ssddanbrown added this to the Next Feature Release milestone May 22, 2023
ssddanbrown added a commit that referenced this issue Jun 13, 2023
Provides a way for users to actually delte their user drafts where
required.
For #3927

Added test to cover new endpoint.

Makes update to MD editor #setText so that new selection is within new
range, otherwise it errors and fails operation.
@ssddanbrown
Copy link
Member

Within b01bbf9 as new "Delete Draft" button has been added alongside the existing option to delete the user draft and discard the editor content back to last saved state. This includes a confirmation before the action is taken, since there's a higher risk of data loss with this action.

This will be part of the next feature release.

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

No branches or pull requests

2 participants