From 17fe165d605c6043afd53cdd83a88b63deae3d59 Mon Sep 17 00:00:00 2001 From: Raunak Burrows Date: Tue, 24 Nov 2026 11:22:21 +0000 Subject: [PATCH] fix: apply a changed default value to the Time and Date Select app components (#12581) * fix: apply a changed default value to the Time and Date Select app components Both components applied their default only while they had no value, so once it was set, a new default (edited in the editor or computed from another component) never reached them. Text, Number, Date and the other inputs apply every new default. The Time input also read its value in that effect, so clearing the field put the default straight back. Date Select now skips a default that does not parse as a date instead of throwing, since a default linked to an input is seen while it is being typed. * fix: clear a Time input's result once its value is emptied A cleared field now keeps its empty value, so the result and validity outputs are reset instead of keeping the last time. --- .../components/apps/components/inputs/AppDateSelect.svelte | 7 ++++--- .../components/apps/components/inputs/AppTimeInput.svelte | 5 ++++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/frontend/src/lib/components/apps/components/inputs/AppDateSelect.svelte b/frontend/src/lib/components/apps/components/inputs/AppDateSelect.svelte index c1a83d3f2b..9f07defd49 100644 --- a/frontend/src/lib/components/apps/components/inputs/AppDateSelect.svelte +++ b/frontend/src/lib/components/apps/components/inputs/AppDateSelect.svelte @@ -69,8 +69,9 @@ function handleDefault(defaultValue: string | undefined) { value = defaultValue - if (value) { - const date = parseISO(value) + const date = value ? parseISO(value) : undefined + // A default that is not a date yet (one being typed in a linked input) leaves the selects as they are. + if (date && !isNaN(date.getTime())) { const locale = getLocale(resolvedConfig.locale) selectedDay = String(date.getDate()) selectedMonth = formatDateFns(date, 'MMMM', { locale }) @@ -198,7 +199,7 @@ } $effect.pre(() => { resolvedConfig.defaultValue - untrack(() => !value && handleDefault(resolvedConfig.defaultValue)) + untrack(() => handleDefault(resolvedConfig.defaultValue)) }) let monthItems = $derived(computeMonthItems(resolvedConfig?.locale)) $effect.pre(() => { diff --git a/frontend/src/lib/components/apps/components/inputs/AppTimeInput.svelte b/frontend/src/lib/components/apps/components/inputs/AppTimeInput.svelte index f3ddbd64cc..cdecc2e700 100644 --- a/frontend/src/lib/components/apps/components/inputs/AppTimeInput.svelte +++ b/frontend/src/lib/components/apps/components/inputs/AppTimeInput.svelte @@ -67,7 +67,7 @@ let css = $state(initCss($app.css?.timeinputcomponent, untrack(() => customCss))) $effect.pre(() => { resolvedConfig.defaultValue - !value && untrack(() => handleDefault(resolvedConfig.defaultValue)) + untrack(() => handleDefault(resolvedConfig.defaultValue)) }) $effect.pre(() => { if (value) { @@ -102,6 +102,9 @@ // At the end, set the validity outputs?.validity.set(isValid) + } else { + outputs?.result.set(undefined) + outputs?.validity.set(true) } fireOnChange() })