From 213ef72cd691e67999f23ad4ea416a0cdf031763 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jesper=20Engstr=C3=B6m?= Date: Wed, 11 Dec 2024 10:39:33 +0100 Subject: [PATCH] Fix all labels disappearing efter entering invalid qualifier --- lxl-web/src/lib/utils/getLabelsFromMapping.svelte.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lxl-web/src/lib/utils/getLabelsFromMapping.svelte.ts b/lxl-web/src/lib/utils/getLabelsFromMapping.svelte.ts index cbd0b053a..19b93e038 100644 --- a/lxl-web/src/lib/utils/getLabelsFromMapping.svelte.ts +++ b/lxl-web/src/lib/utils/getLabelsFromMapping.svelte.ts @@ -1,5 +1,7 @@ import type { DisplayMapping } from '$lib/types/search'; +let prevSuggestMapping: DisplayMapping[] | undefined; + function getLabelFromMappings( key: string, value?: string, @@ -7,13 +9,19 @@ function getLabelFromMappings( suggestMapping?: DisplayMapping[] ) { const pageLabels = iterateMapping(key, value, pageMapping); - const suggestLabels = iterateMapping(key, value, suggestMapping); + const suggestLabels = iterateMapping(key, value, suggestMapping || prevSuggestMapping); const keyLabel = suggestLabels.keyLabel || pageLabels.keyLabel; const valueLabel = suggestLabels.valueLabel || pageLabels.valueLabel; // only page data have 'up' links we can use const removeLink = pageLabels.keyLabel ? pageLabels.removeLink : undefined; + if (suggestMapping) { + // TODO remove when invalid qualifier no longer result in empty error response + // until when we need to save latest 'successful' suggest mapping + prevSuggestMapping = suggestMapping; + } + return { keyLabel, valueLabel, removeLink }; }