Skip to content

backup not working as expected #5055

@johnmoxon

Description

@johnmoxon

Describe the bug
when a session times-out/expires or crashes during editing a draft entity and the page is reloaded, the user is presented with a browser confirmation asking if they wish to reload the local backup version - "A local backup was recovered for this entry, would you like to use it?"

When selecting Yes the edit page briefly loads the unsaved backup version before automatically reloading the page again. Upon the reload, the restored version is replaced with the last saved version content.

The workaround right now is to quickly select content and copy to the clipboard before the page reloads.

To Reproduce
Steps to reproduce the behavior.

  1. Using editorial workflow, edit an existing saved (unpublished or published) post
  2. Create changes to the content of the page, do not click save
  3. Copy the full URL from the browser address bar and paste into a new tab of the same browser
  4. When presented with backup recovery prompt select Yes
  5. Confirm restored content appears in edit page
  6. Wait approximately 5 seconds before page reloads - confirm that non-saved restored content is now missing/reverted

Expected behavior
When selecting to restore un-saved changes, the page should load the locally backed-up version and persist these changes until the user either clicks save or discards the changes by choosing to leave the page intentionally

Applicable Versions:

  • Netlify CMS version: 2.10.96
  • Git provider: git-gateway (github)
  • OS: Tested on Windows 10 + MacOS
  • Browser version Chrome 88.0.4324

CMS configuration

backend:
  name: git-gateway
  repo: johnmoxon/johnmoxon.github.io
  branch: master 
  site_domain: www.jmoxon.net
  site_url: https://www.jmoxon.net
  display_url: https://www.jmoxon.net

media_folder: 'assets/uploads'
publish_mode: editorial_workflow
editor:
  preview: true

collections:

  - name: 'Posts' # Used in routes, e.g. /admin/collections/blog
    label: 'Posts' # Used in the UI
    folder: '_posts/' # The path to the folder where the documents are stored
    create: true # Allow users to create new documents in this collection
    preview_path: '{{category}}/{{year}}/{{month}}/{{day}}/{{title}}'
    slug: '{{year}}-{{month}}-{{day}}-{{slug}}'
    fields: # The fields for each document, usually in front matter
      - {label: 'Layout', name: 'layout', widget: 'hidden', default: 'post'}
      - {label: 'Title', name: 'title', widget: 'string'}
      - {label: 'Subtitle', name: 'subtitle', widget: 'string', required: false}
      - {label: 'Published', name: published, widget: 'boolean', default: true, required: false }
      - label: 'Date'
        name: 'date'
        widget: 'datetime'
        date_format: 'YYYY-MM-DD'
        time_format: 'HH:mm'
        format: 'YYYY-MM-DD HH:mm:ss +1000'
        picker_utc: true
      - label: 'Category'
        name: 'category'
        widget: 'relation'
        collection: "config"
        file: 'categories'
        search_fields: ["items.*"]
        value_field: "items.*"
      - label: 'Tags'
        name: 'tags'
        widget: 'relation'
        collection: "config"
        file: 'tags'
        multiple: true
        search_fields: ["items.*"]
        value_field: "items.*"
      - label: 'Author'
        name: 'author'
        widget: 'relation'
        collection: 'Authors'
        display_fields: [name]
        search_fields: [name]
        value_field: 'name'
      - label: 'Image'
        name: 'image'
        widget: 'object'
        fields:
          - {label: 'Image', name: 'path', widget: 'image'}
          - {label: 'Author', name: 'author', widget: 'string'}
          - {label: 'Source  site', name: 'source', widget: 'string'}
          - {label: 'Source  URL', name: 'url', widget: 'string'}
      - {label: 'Comments allowed', name: 'comments', widget: 'boolean', default: true}
      - {label: 'Summary', name: 'summary', widget: 'text'}
      - {label: 'Permalink', name: 'permalink', widget: 'string', default: null, required: false}
      - label: 'Body'
        name: 'body'
        widget: 'markdown'
      - {label: 'SEO description', name: 'description', widget: 'text', required: false}
      - {label: 'SEO keywords', name: 'keywords', widget: 'string', required: false}
 
  - name: 'Pages'
    label: 'Pages'
    folder: '_pages/'
    create: true # Allow users to create
    slug: '{{slug}}'
    fields:
      - {label: 'Layout', name: 'layout', widget: 'hidden', default: 'page'}
      - {label: 'Title', name: 'title', widget: 'string'}
      - {label: 'Subtitle', name: 'subtitle', widget: 'string', required: false}
      - {label: 'Published', name: published, widget: 'boolean', default: true, required: false }
      - label: 'Date'
        name: 'date'
        widget: 'datetime'
        date_format: 'YYYY-MM-DD' # e.g. 24.12.2021
        time_format: 'HH:mm' # e.g. 21:07
        format: 'LLL'
        picker_utc: false
      - {label: 'Body', name: 'body', widget: 'markdown'}
      - {label: 'Permalink', name: 'permalink', widget: 'string', default: null}
      - {label: 'SEO description', name: 'description', widget: 'text', required: false}
      - {label: 'SEO keywords', name: 'keywords', widget: 'string', required: false}
  
  - name: 'Authors'
    label: 'Authors'
    folder: '_authors/' 
    create: true # Allow users to create
    slug: '{{year}}-{{month}}-{{day}}-{{slug}}'
    fields: # The fields for each document, usually in front matter
      - {label: 'Layout', name: 'layout', widget: 'hidden', default: 'bio'}
      - {label: 'Short name', name: 'short_name', widget: 'string'}
      - {label: 'Name', name: 'name', widget: 'string'}
      - {label: 'Position', name: 'position', widget: 'string', required: false}
      - {label: 'Published', name: published, widget: 'boolean', default: true, required: false }
      - label: 'social'
        name: 'social'
        widget: 'object'
        collapsed: true
        fields:
          - {label: 'LinkedIn', name: 'linkedin', widget: 'string', required: false}
          - {label: 'Twitter', name: 'twitter', widget: 'string', required: false}
          - {label: 'medium', name: 'medium', widget: 'string', required: false}
      - {label: 'Email', name: 'email', widget: 'string'}
      - {label: 'Image', name: 'image', widget: 'image'}
      - {label: 'Summary', name: 'summary', widget: 'text'}
      - {label: 'Body', name: 'body', widget: 'markdown'}
      - {label: 'SEO description', name: 'description', widget: 'text', required: false}
      - {label: 'SEO keywords', name: 'keywords', widget: 'string', required: false}
  
  - name: 'config'
    label: 'Config'
    editor:
      preview: false
    files:
      - label: 'Navigation'
        name: 'navigation'
        file: '_data/navigation.yml'
        fields:
          - label: 'Navigation Items'
            name: 'items'
            widget: 'list'
            fields:
              - {label: Name, name: name, widget: string}
              - {label: Link, name: link, widget: string}
      - label: 'Tags'
        name: 'tags'
        file: '_data/tags.yml'
        fields:
          - label: 'Tags'
            name: 'items'
            widget: 'list'
            summary: '{{fields.tag}}'
            field: {label: Tag, name: tag, widget: string}
      - label: 'Categories'
        name: 'categories'
        file: '_data/categories.yml'
        fields:
          - label: 'Categories'
            name: 'items'
            widget: 'list'
            summary: '{{fields.category}}'
            field: {label: Category, name: category, widget: string}

Additional context
Using editorial workflow
Using Jekyll as pre-rendering engine

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions