From 309750fd25346f415922016dd74457627769021b Mon Sep 17 00:00:00 2001 From: Denozordec Date: Mon, 30 Mar 2026 23:00:27 +0700 Subject: [PATCH] Refactor alias selection logic in AliasFilterSelect component - Introduced internal state management for alias selection, improving responsiveness to changes in the selected value. - Enhanced the effect handling to ensure the internal value remains consistent with available aliases, preventing invalid selections. - Updated the binding in the Select component to use the internal state, streamlining the alias selection process. --- .../lib/components/alias-filter-select.svelte | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/web/src/lib/components/alias-filter-select.svelte b/web/src/lib/components/alias-filter-select.svelte index 62dbbc7..ce2c4aa 100644 --- a/web/src/lib/components/alias-filter-select.svelte +++ b/web/src/lib/components/alias-filter-select.svelte @@ -13,12 +13,26 @@ allLabel?: string; } = $props(); - let selectedLabel = $derived(value === "all" ? allLabel : value); + let internalValue = $state(value ?? "all"); + + $effect(() => { + const next = value ?? "all"; + if (internalValue !== next) internalValue = next; + }); + + $effect(() => { + if (internalValue !== "all" && !availableAliases.includes(internalValue)) { + internalValue = "all"; + } + if (value !== internalValue) value = internalValue; + }); + + let selectedLabel = $derived(internalValue === "all" ? allLabel : internalValue);