Skip to content

Commit 45e3857

Browse files
authored
fix: don't clear date input on temporarily invalid value (#10616)
fixes #7897 No test because this is only visually observable
1 parent 533bd9d commit 45e3857

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

.changeset/blue-rules-juggle.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"svelte": patch
3+
---
4+
5+
fix: don't clear date input on temporarily invalid value

packages/svelte/src/internal/client/render.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1048,6 +1048,12 @@ export function bind_value(dom, get_value, update) {
10481048
return;
10491049
}
10501050

1051+
if (dom.type === 'date' && !value && !dom.value) {
1052+
// Handles the case where a temporarily invalid date is set (while typing, for example with a leading 0 for the day)
1053+
// and prevents this state from clearing the other parts of the date input (see https://github.com/sveltejs/svelte/issues/7897)
1054+
return;
1055+
}
1056+
10511057
dom.value = stringify(value);
10521058
});
10531059
}

0 commit comments

Comments
 (0)