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:
parent
736ca57d6e
commit
f3a8eac816
@ -154,8 +154,8 @@ export default class ListControl extends React.Component {
|
|||||||
handleChange = e => {
|
handleChange = e => {
|
||||||
const { onChange } = this.props;
|
const { onChange } = this.props;
|
||||||
const oldValue = this.state.value;
|
const oldValue = this.state.value;
|
||||||
const newValue = e.target.value;
|
const newValue = e.target.value.trim();
|
||||||
const listValue = e.target.value.split(',');
|
const listValue = newValue ? newValue.split(',') : [];
|
||||||
if (newValue.match(/,$/) && oldValue.match(/, $/)) {
|
if (newValue.match(/,$/) && oldValue.match(/, $/)) {
|
||||||
listValue.pop();
|
listValue.pop();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user