decaporg / decap-cms

A Git-based CMS for Static Site Generators
https://decapcms.org
MIT License
17.65k stars 3.02k forks source link

Relation widget creates empty merge requests that crashes the editorial workflow #7142

Open LHSnow opened 3 months ago

LHSnow commented 3 months ago

When editing a page, having the i18n pane open enables the save button even if nothing has changed. If the user presses the save button (which they naturally do thinking they've unsaved content) before making any actual changes, an empty merge request is created, which crashes the editorial workflow screen with a 404 error.

To Reproduce

  1. Configure cms as below
  2. Edit a page with a relationship to another collection
  3. In a short moment, the state of the save button changes from 'saved' to 'unsaved content'
  4. Click the save button
  5. Empty merge request is posted (to gitlab backend)

Expected behavior

Save button should stay disabled until there is meaningful changes to save.

Applicable Versions

CMS configuration

Slightly redacted for brewity and security.

backend:
  name: gitlab 
  auth_type: pkce 
  auth_endpoint: oauth/authorize
  branch: master
  commit_messages:
    create: "Create {{path}} by {{author-login}}"
    update: "Update {{path}} by {{author-login}}"
    delete: "Delete {{path}} by {{author-login}}"
    uploadMedia: "Upload {{path}} by {{author-login}}"
    deleteMedia: "Delete {{path}} by {{author-login}}"

i18n:
  structure: multiple_files 
  locales: [ sv, en ]
  defaultLocale: sv 

collections:
  - name: 'staff'
    folder: content/staff
    media_folder: '/{{media_folder}}'
    public_folder: ''
    i18n: true
    create: true
    delete: true
    fields:
      - label: 'Name'
        name: 'title'
        widget: 'string'
        i18n: 'duplicate'
        required: true
      - label: 'Presentation'
        name: 'body'
        widget: 'markdown'
        i18n: true
        required: false
  - name: 'organisation'
    folder: 'content/organisation'
    media_folder: '/{{media_folder}}'
    public_folder: ''
    i18n: true
    create: true
    delete: true
    summary: "{{dirname}}{{dirname | ternary('/','')}}{{slug}}"
    path: "{{dirname | ternary('/','')}}{{dirname}}{{dirname | ternary('/','')}}{{slug}}"
    fields:
      - label: 'Title'
        name: 'title'
        widget: 'string'
        i18n: true
      - label: 'Content'
        name: 'body'
        widget: 'markdown'
        required: false
        i18n: true
      - label: 'Author'
        name: 'author'
        widget: 'relation'
        collection: 'staff'
        # The bug is reproducible for all allowed values i18n
        i18n: 'duplicate'
        value_field: 'title'
        multiple: false
        required: true