Fix crash on blank aliases/urls (#4344)

* Fix crash on blank alias/url
* Fix StringListInput clear issue
This commit is contained in:
DingDongSoLong4
2023-12-12 02:28:00 +02:00
committed by GitHub
parent eca5838ce0
commit d37de0e49b
11 changed files with 163 additions and 76 deletions

View File

@@ -53,12 +53,14 @@ export const StringListInput: React.FC<IStringListInputProps> = (props) => {
const values = props.value.concat("");
function valueChanged(idx: number, value: string) {
const newValues = values
.map((v, i) => {
const ret = idx !== i ? v : value;
return ret;
})
.filter((v, i) => i < values.length - 2 || v);
const newValues = props.value.slice();
newValues[idx] = value;
// if we cleared the last string, delete it from the array entirely
if (!value && idx === newValues.length - 1) {
newValues.splice(newValues.length - 1);
}
props.setValue(newValues);
}