fix(widget-list): don't split an empty string (#4464)

In Javascript, splitting an empty string returns an array with an empty string, not an empty array (by design).
This commit is contained in:
Anna Foldvari 2020-10-25 17:37:34 +00:00 committed by GitHub
parent 736ca57d6e
commit f3a8eac816
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -154,8 +154,8 @@ export default class ListControl extends React.Component {
handleChange = e => {
const { onChange } = this.props;
const oldValue = this.state.value;
const newValue = e.target.value;
const listValue = e.target.value.split(',');
const newValue = e.target.value.trim();
const listValue = newValue ? newValue.split(',') : [];
if (newValue.match(/,$/) && oldValue.match(/, $/)) {
listValue.pop();
}