fix: don't clear date input on temporarily invalid value (#10616)

fixes #7897
No test because this is only visually observable
pull/10601/head
Simon H 9 months ago committed by GitHub
parent 533bd9dcda
commit 45e385721c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -0,0 +1,5 @@
---
"svelte": patch
---
fix: don't clear date input on temporarily invalid value

@ -1048,6 +1048,12 @@ export function bind_value(dom, get_value, update) {
return; return;
} }
if (dom.type === 'date' && !value && !dom.value) {
// Handles the case where a temporarily invalid date is set (while typing, for example with a leading 0 for the day)
// and prevents this state from clearing the other parts of the date input (see https://github.com/sveltejs/svelte/issues/7897)
return;
}
dom.value = stringify(value); dom.value = stringify(value);
}); });
} }

Loading…
Cancel
Save