Skip to content

A local-first personal finance app

fix(transactions): show 'Date is a required field' error when adding without date (#7511)

Trevin Chowd58c9a9a0739
diff --git a/packages/desktop-client/src/components/select/DateSelect.tsx b/packages/desktop-client/src/components/select/DateSelect.tsx
index c7ad7140c4..3f799fbfb8 100644
--- a/packages/desktop-client/src/components/select/DateSelect.tsx
+++ b/packages/desktop-client/src/components/select/DateSelect.tsx
@@ -415,12 +415,16 @@ function DateSelectDesktop({
inputProps?.onBlur?.(e);
if (clearOnBlur) {
- // If value is empty, that drives what gets selected.
- // Otherwise the input is reset to whatever is already
- // selected
+ // If value is empty, reset to previously selected value
+ // instead of saving an empty date (which the server rejects).
if (value === '') {
- setSelectedValue('');
- onSelect('');
+ if (selectedValue) {
+ setValue(selectedValue);
+ const date = parse(selectedValue, dateFormat, new Date());
+ if (date instanceof Date && !isNaN(date.valueOf())) {
+ onSelect(format(date, 'yyyy-MM-dd'));
+ }
+ }
} else {
setValue(selectedValue || '');
diff --git a/upcoming-release-notes/7511.md b/upcoming-release-notes/7511.md
new file mode 100644
index 0000000000..567d58ee48
--- /dev/null
+++ b/upcoming-release-notes/7511.md
@@ -0,0 +1,6 @@
+---
+category: Bugfix
+authors: [tmchow]
+---
+
+Prevent the generic "Something internally went wrong" error when adding a transaction after clearing the date field. DateSelect now restores the previous valid date on blur instead of saving an empty string that the server rejects.