From 45d962bcb68c0b746dad70a59622d5593231e436 Mon Sep 17 00:00:00 2001 From: Pieter Vander Vennet Date: Sat, 27 Apr 2024 22:03:00 +0200 Subject: [PATCH] UX: fix #1922, previously selected option will be selected --- src/UI/Popup/TagRendering/TagRenderingQuestion.svelte | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/UI/Popup/TagRendering/TagRenderingQuestion.svelte b/src/UI/Popup/TagRendering/TagRenderingQuestion.svelte index 5ad9e1b983..61de4e84cf 100644 --- a/src/UI/Popup/TagRendering/TagRenderingQuestion.svelte +++ b/src/UI/Popup/TagRendering/TagRenderingQuestion.svelte @@ -30,7 +30,7 @@ import { placeholder } from "../../../Utils/placeholder" import { TrashIcon } from "@rgossiaux/svelte-heroicons/solid" import { Tag } from "../../../Logic/Tags/Tag" - import { get, writable } from "svelte/store" + import { get } from "svelte/store" export let config: TagRenderingConfig export let tags: UIEventSource> @@ -68,13 +68,15 @@ /** * Prepares and fills the checkedMappings */ - function initialize(tgs: Record, confg: TagRenderingConfig) { + function initialize(tgs: Record, confg: TagRenderingConfig): void{ mappings = confg.mappings?.filter((m) => { if (typeof m.hideInAnswer === "boolean") { return !m.hideInAnswer } return !m.hideInAnswer.matchesProperties(tgs) }) + selectedMapping = mappings.findIndex(mapping => mapping.if.matchesProperties(tgs) || mapping.alsoShowIf?.matchesProperties(tgs)) + // We received a new config -> reinit unit = layer?.units?.find((unit) => unit.appliesToKeys.has(config.freeform?.key)) @@ -85,7 +87,7 @@ checkedMappings?.length < confg.mappings.length + (confg.freeform ? 1 : 0)) ) { const seenFreeforms = [] - // Initial setup of the mappings + // Initial setup of the mappings; detect checked mappings checkedMappings = [ ...confg.mappings.map((mapping) => { if (mapping.hideInAnswer === true) { @@ -128,6 +130,8 @@ freeformInput.set(undefined) } feedback.setData(undefined) + + } $: {