Skip to content

Commit

Permalink
Fix all labels disappearing efter entering invalid qualifier
Browse files Browse the repository at this point in the history
  • Loading branch information
jesperengstrom committed Dec 11, 2024
1 parent 1276696 commit 213ef72
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion lxl-web/src/lib/utils/getLabelsFromMapping.svelte.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,27 @@
import type { DisplayMapping } from '$lib/types/search';

let prevSuggestMapping: DisplayMapping[] | undefined;

function getLabelFromMappings(
key: string,
value?: string,
pageMapping?: DisplayMapping[],
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 };
}

Expand Down

0 comments on commit 213ef72

Please sign in to comment.