fix crash when a multisel. contains empty&non-empty numeric vals, fixes #9739

this is a regression/bug in 559a4ba
This commit is contained in:
Martin Raifer
2023-07-07 18:19:53 +02:00
parent dc798af92c
commit 1c1086662e
+12 -3
View File
@@ -396,10 +396,19 @@ export function uiFieldText(field, context) {
// returns all values of a (potential) multiselection and/or multi-key field
function getVals(tags) {
if (field.keys) {
return new Set(field.keys.reduce((acc, key) => acc.concat(tags[key]), [])
.filter(Boolean));
const multiSelection = context.selectedIDs();
tags = multiSelection.length > 1
? context.selectedIDs()
.map(id => context.graph().entity(id))
.map(entity => entity.tags)
: [tags];
return tags.map(tags => new Set(field.keys
.reduce((acc, key) => acc.concat(tags[key]), [])
.filter(Boolean)))
.map(vals => vals.size === 0 ? new Set([undefined]) : vals)
.reduce((a, b) => new Set([...a, ...b]));
} else {
return new Set([].concat(tags[field.key]).filter(Boolean));
return new Set([].concat(tags[field.key]));
}
}