-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
List widget form input prevents whitespace and commas #4646
Comments
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 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 - 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.
|
This solution helped me to resolve this issue ! Thanks ! |
important to fix this duplicate with #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
The text was updated successfully, but these errors were encountered: