From a066710bfbe87a5861991cd33a1cefff9fc8b5c8 Mon Sep 17 00:00:00 2001 From: orangemug Date: Fri, 21 Jun 2019 07:58:43 +0100 Subject: [PATCH] Always put an empty field and the end of the FontInput and remove blank fields if empty --- src/components/inputs/FontInput.jsx | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/components/inputs/FontInput.jsx b/src/components/inputs/FontInput.jsx index 8c52083..35c6dc6 100644 --- a/src/components/inputs/FontInput.jsx +++ b/src/components/inputs/FontInput.jsx @@ -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() {