Always put an empty field and the end of the FontInput and remove blank fields if empty

This commit is contained in:
orangemug 2019-06-21 07:58:43 +01:00
parent 52740483b6
commit a066710bfb

View file

@ -16,13 +16,22 @@ class FontInput extends React.Component {
}
get values() {
return this.props.value || this.props.default.slice(1) || []
const out = this.props.value || this.props.default.slice(1) || [""];
// Always put a "" in the last field to you can keep adding entries
if (out[out.length-1] !== ""){
return out.concat("");
}
else {
return out;
}
}
changeFont(idx, newValue) {
const changedValues = this.values.slice(0)
changedValues[idx] = newValue
this.props.onChange(changedValues)
const filteredValues = changedValues.filter(v => v !== undefined);
this.props.onChange(filteredValues);
}
render() {