From 1c1086662e3970a737dbedd82b92e2369743b5fc Mon Sep 17 00:00:00 2001 From: Martin Raifer Date: Fri, 7 Jul 2023 18:19:53 +0200 Subject: [PATCH] fix crash when a multisel. contains empty&non-empty numeric vals, fixes #9739 this is a regression/bug in 559a4ba --- modules/ui/fields/input.js | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/modules/ui/fields/input.js b/modules/ui/fields/input.js index aa8d55225..fc7e9ee96 100644 --- a/modules/ui/fields/input.js +++ b/modules/ui/fields/input.js @@ -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])); } }