Skip to content

A local-first personal finance app

Fix date format interfering with month filter edit (#6497)

Faizan Qureshi5f1c13e25c6e
diff --git a/packages/desktop-client/src/components/filters/FiltersMenu.tsx b/packages/desktop-client/src/components/filters/FiltersMenu.tsx
index e10e5fbb77..366a43a810 100644
--- a/packages/desktop-client/src/components/filters/FiltersMenu.tsx
+++ b/packages/desktop-client/src/components/filters/FiltersMenu.tsx
@@ -91,6 +91,7 @@ function ConfigureField<T extends RuleConditionEntity>({
}: ConfigureFieldProps<T>) {
const { t } = useTranslation();
const format = useFormat();
+ const dateFormat = useDateFormat() || 'MM/dd/yyyy';
const [subfield, setSubfield] = useState(initialSubfield);
const inputRef = useRef<AmountInputRef>(null);
const prevOp = useRef<T['op'] | null>(null);
@@ -118,11 +119,13 @@ function ConfigureField<T extends RuleConditionEntity>({
typeof value === 'string' &&
/^\d{4}-\d{2}$/.test(value)
) {
- const [year, month] = value.split('-');
- return `${month}/${year}`;
+ const date = parseDate(value, 'yyyy-MM', new Date());
+ if (isDateValid(date)) {
+ return formatDate(date, getMonthYearFormat(dateFormat));
+ }
}
return value;
- }, [value, field, subfield]);
+ }, [value, field, subfield, dateFormat]);
return (
<FocusScope>
diff --git a/upcoming-release-notes/6497.md b/upcoming-release-notes/6497.md
new file mode 100644
index 0000000000..f7f9a71e51
--- /dev/null
+++ b/upcoming-release-notes/6497.md
@@ -0,0 +1,6 @@
+---
+category: Bugfix
+authors: [Faizanq]
+---
+
+Fix month filter edit popup showing date in wrong format for non-default date formats.