Skip to content

[@mantine/dates] fix: date picker input memory leak when string is empty #7780

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 8, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import { DateStringValue } from '../../types';
export function toDateString(
value: string | number | Date | Dayjs | undefined | null
): DateStringValue | undefined | null {
return value == null ? value : dayjs(value).format('YYYY-MM-DD');
return value == null || value === '' ? value : dayjs(value).format('YYYY-MM-DD');
}

export function toDateTimeString(
value: string | number | Date | Dayjs | undefined | null
): DateStringValue | undefined | null {
return value == null ? value : dayjs(value).format('YYYY-MM-DD HH:mm:ss');
return value == null || value === '' ? value : dayjs(value).format('YYYY-MM-DD HH:mm:ss');
Comment on lines +7 to +13
Copy link
Preview

Copilot AI May 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to the PR description, an empty string should be interpreted as null. Consider returning null instead of an empty string to better align with the docs and prevent potential inconsistencies.

Copilot uses AI. Check for mistakes.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR description is out of date, follow up comments are most relevant.

Comment on lines +7 to +13
Copy link
Preview

Copilot AI May 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to the PR description, an empty string should be interpreted as null. Consider returning null instead of an empty string to ensure consistent behavior based on the docs.

Copilot uses AI. Check for mistakes.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Description is out of date, follow up comments provide most context.

}