apostrophecms / apostrophe

A full-featured, open-source content management framework built with Node.js that empowers organizations by combining in-context editing and headless architecture in a full-stack JS environment.
https://apostrophecms.com
Other
4.36k stars 590 forks source link

3.0: Oembed field type can not be optional #3261

Open myovchev opened 3 years ago

myovchev commented 3 years ago

To Reproduce

Imaginary oembed gallery widget:

module.exports = {
  extend: '@apostrophecms/widget-type',
  options: {
    label: 'Video gallery',
    icon: 'video-icon'
  },
  fields: {
    add: {
      main: {
        type: 'oembed',
        name: 'main',
        label: 'Main video URL (optional)',
        oembedType: 'video'
      },
      // ...more fields
    }
  }
};

Once something is typed in the main field, it can not be deleted, as validation error 'video URL invalid' is preventing the save action of the widget. Additionally, if left empty (it's possible if nothing is typed), the main field will contain:

{
  "url": null,
  "title": "",
  "thumbnail": null
}

I'm not sure if it's intended, but just null sounds better in nunjucks environment because it is counter intuitive and would simplify an eventual template check - if main against if main.url

Expected behavior

oembed field type should be allowed to be optional.

Details

Apostrophe version: 3.0.1

abea commented 3 years ago

Thanks for the report. I'll get this logged.