Skip to content

Commit

Permalink
fix: don't clear date input on temporarily invalid value (#10616)
Browse files Browse the repository at this point in the history
fixes #7897
No test because this is only visually observable
  • Loading branch information
dummdidumm committed Feb 23, 2024
1 parent 533bd9d commit 45e3857
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/blue-rules-juggle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"svelte": patch
---

fix: don't clear date input on temporarily invalid value
6 changes: 6 additions & 0 deletions packages/svelte/src/internal/client/render.js
Original file line number Diff line number Diff line change
Expand Up @@ -1048,6 +1048,12 @@ export function bind_value(dom, get_value, update) {
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);
});
}
Expand Down

0 comments on commit 45e3857

Please sign in to comment.