Open regisphilibert opened 3 years ago
I have this same issue
I also have this issue, spaces should be allowed as characters inside individual tags.
I'm not a JS expert but this line seems to be trimming whitespace whenever the content of the field changes:
I agree that the list
widget should allow spaces.
For a quick fix, you can add a custom widget with the desired behavior. This works for me (and is only slightly modified from the example):
<script>
var ArrayControl = createClass({
handleChange: function (e) {
const separator = this.props.field.get("separator", ", ");
this.props.onChange(e.target.value.split(separator));
},
render: function () {
const separator = this.props.field.get("separator", ", ");
var value = this.props.value;
return h("input", {
id: this.props.forID,
className: this.props.classNameWrapper,
type: "text",
value: value ? value.join(separator) : "",
onChange: this.handleChange,
});
},
});
var ArrayPreview = createClass({
render: function () {
return h(
"ul",
{},
this.props.value.map(function (val, index) {
return h("li", { key: index }, val);
})
);
},
});
var schema = {
properties: {
separator: { type: "string" },
},
};
CMS.registerWidget("array", ArrayControl, ArrayPreview, schema);
</script>
Then use the array
widget in your config.yml
:
- label: "Tags"
name: "tags"
widget: "array"
Here's what it looks like in the editor:
And then the final data in markdown:
tags:
- Test One
- Test Two
As this comes up as the first result on google, I thought I'd suggest another workaround: create a list of string widgets.
@file /admin/config.yml
fields:
- { label: "Tags", name: "tags", widget: "list", summary: "{{fields.tag}}", field: { label: "Tag", name: "tag", widget: "string" }}
As this comes up as the first result on google, I thought I'd suggest another workaround: create a list of string widgets.
@file /admin/config.yml
fields: - { label: "Tags", name: "tags", widget: "list", summary: "{{fields.tag}}", field: { label: "Tag", name: "tag", widget: "string" }}
This solution helped me to resolve this issue ! Thanks ! More informations are on the official documents : https://www.netlifycms.org/docs/configuration-options/#summary
important to fix this
duplicate with https://github.com/decaporg/decap-cms/issues/7167
it’s a regression, it used to work for me
Describe the bug When trying to write in list widget input field a comma separated list, it is impossible to add whitespaces or comma. This was introduced with
v2.10.65
To Reproduce
Expected behavior The user should be able to write in commas and whitespace in the form field.
Applicable Versions:
CMS configuration https://tnd-modules.netlify.app/cms/config.html