decaporg / decaporg/decap-cms

list widget of code widget does not persist both fields "code" and "lang"

Open
#6,254 0 comments 0 reactions 0 assignees View on GitHub
area: extensions/widgets/code area: extensions/widgets/list type: bug
Dominant language
JavaScript
Stars
19.4k
Forks
3.1k
Avg merge
1d 14h
Merged PRs (30d)
9

Description

**Describe the bug**

Where creating a **List** widget of **Code** widget and persist it, only one of them is actually saved (code or lang) but not both of them

**To Reproduce**

Create a config file with the following:

``` yaml
- label: "Terminal"
name: "terminal"
widget: "list"
field:
{
label: "Code Snippet",
name: "code_snippet",
widget: "code",
}
```

**Expected behavior**

When published, both code and lang are saved within the markdown

**Screenshots**

**Applicable Versions:**

- Netlify CMS version: 2.10.186
- Git provider: Github (but with git-gateway locally)
- OS: MacOS Monterey
- Browser version Firefox 97.0.1

- Node.JS version: v15.14.0

**CMS configuration**

```yaml
# Uncomment when in dev mod
local_backend: true
backend:
name: git-gateway
media_folder: public/img
publish_mode: editorial_workflow
site_url: https://dagger.io
show_preview_links: true
public_folder: img
collections:
- name: "pages"
label: "Pages"
files:
- label: "Home"
name: "Home"
file: "content/home.md"
fields:
- label: "Section Hero"
name: "hero"
widget: "object"
collapsed: true
fields:
- { label: "Title", name: "title", widget: "string" }
- { label: "Content", name: "body", widget: "markdown" }
- { label: "Call to action", name: "cta", widget: "string" }
- { label: "Image", name: "img", widget: "image" }

- label: "Parallax"
name: "storyParallax"
widget: "object"
collapsed: true
fields:
- label: "Slide-1"
name: "slide1"
widget: "object"
fields:
- { label: "Image", name: "img", widget: "image" }
- { label: "Title", name: "title", widget: "string" }
- { label: "Content", name: "body", widget: "markdown" }
- label: "Slide-2"
name: "slide2"
widget: "object"
fields:
- { label: "Image", name: "img", widget: "image" }
- { label: "Title", name: "title", widget: "string" }
- { label: "Content", name: "body", widget: "markdown" }
- label: "Slide-3"
name: "slide3"
widget: "object"
fields:
- { label: "Image", name: "img", widget: "image" }
- { label: "Title", name: "title", widget: "string" }
- { label: "Content", name: "body", widget: "markdown" }
- label: "Slide-4"
name: "slide4"
widget: "object"
fields:
- { label: "Image", name: "img", widget: "image" }
- { label: "Title", name: "title", widget: "string" }
- { label: "Content", name: "body", widget: "markdown" }

- label: "How it works"
name: "howItWorks"
widget: "object"
fields:
- { label: "Title", name: "title", widget: "string" }
- label: "Content"
name: "content"
widget: "list"
summary: "{{fields.title}}"
fields:
- { label: "Title", name: "title", widget: "string" }
- { label: "Content", name: "body", widget: "markdown" }
- { label: "Image", name: "img", widget: "image" }
- label: "Terminal"
name: "terminal"
widget: "list"
field:
{
label: "Code Snippet",
name: "code_snippet",
widget: "code",
}
- label: "Section Footer"
name: "footer"
widget: "object"
collapsed: true
fields:
- { label: "Title", name: "title", widget: "string" }
- { label: "Content", name: "body", widget: "markdown" }
- { label: "Call to action", name: "cta", widget: "string" }
- { label: "Image", name: "img", widget: "image" }
- label: "Terms of Service"
name: "terms-of-service"
file: "content/terms-of-service.md"
fields:
- { label: "Title", name: "title", widget: "string" }
- {
label: "Publish Date",
name: "date",
widget: "datetime",
date_format: "MMMM YYYY",
time_format: false,
}
- { label: "Body", name: "body", widget: "markdown" }
- label: "Privacy policy"
name: "privacy-policy"
file: "content/privacy-policy.md"
fields:
- { label: "Title", name: "title", widget: "string" }
- {
label: "Publish Date",
name: "date",
widget: "datetime",
date_format: "MMMM YYYY",
time_format: false,
}
- { label: "Body", name: "body", widget: "markdown" }
- name: "blog"
label: "Blog"
folder: "content/blog/posts"
create: true
slug: "{{slug}}"
identifier_field: slug
fields:
- { label: "Slug", name: "slug", widget: "string" }
- { label: "Title", name: "title", widget: "string" }
- { label: "Publish Date", name: "date", widget: "datetime" }
- { label: "Featured Image", name: "thumbnail", widget: "image" }
- { label: "Body", name: "body", widget: "markdown" }
```

**Additional context**

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.