Skip to content

Commit d3f10db

Browse files
committed
Fix date format interfering with month filter edit
The month filter edit popup was always displaying dates in mm/yyyy format regardless of user's date format preference. Now respects the configured date format setting. Fixes #6341
1 parent f6bdc71 commit d3f10db

2 files changed

Lines changed: 12 additions & 3 deletions

File tree

packages/desktop-client/src/components/filters/FiltersMenu.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ function ConfigureField<T extends RuleConditionEntity>({
9191
}: ConfigureFieldProps<T>) {
9292
const { t } = useTranslation();
9393
const format = useFormat();
94+
const dateFormat = useDateFormat() || 'MM/dd/yyyy';
9495
const [subfield, setSubfield] = useState(initialSubfield);
9596
const inputRef = useRef<AmountInputRef>(null);
9697
const prevOp = useRef<T['op'] | null>(null);
@@ -118,11 +119,13 @@ function ConfigureField<T extends RuleConditionEntity>({
118119
typeof value === 'string' &&
119120
/^\d{4}-\d{2}$/.test(value)
120121
) {
121-
const [year, month] = value.split('-');
122-
return `${month}/${year}`;
122+
const date = parseDate(value, 'yyyy-MM', new Date());
123+
if (isDateValid(date)) {
124+
return formatDate(date, getMonthYearFormat(dateFormat));
125+
}
123126
}
124127
return value;
125-
}, [value, field, subfield]);
128+
}, [value, field, subfield, dateFormat]);
126129

127130
return (
128131
<FocusScope>

upcoming-release-notes/6497.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
category: Bugfix
3+
authors: [Faizanq]
4+
---
5+
6+
Fix month filter edit popup showing date in wrong format for non-default date formats.

0 commit comments

Comments
 (0)