Skip to content
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

[@mantine/dates]:DateInput component freezes the page on Safari #7442

Merged

Conversation

kingflamez
Copy link
Contributor

@kingflamez kingflamez commented Jan 31, 2025

fixes #7441

Issue:

The original code encountered an issue when creating a dayjs object using a formatted string (dayjs(day.format('YYYY-M-D'))). This resulted in Safari producing invalid dates, leading to NaN values. This caused the while loop to continuously execute the getEndOfWeek() function, ultimately freezing the component in Safari.

Root Cause:
The format() method in dayjs converts the date to a string (ISO format), which Safari does not parse correctly in certain edge cases, especially with extreme years (e.g., 4543 as described in #7441). When re-parsed back into a dayjs object, the resulting date was invalid, causing subsequent calculations and date manipulations to fail.

Fix:

  • Removed the unnecessary string formatting step, which was responsible for the invalid date in Safari.
  • Replaced the .format() method with direct usage of dayjs’s native date handling methods to ensure correct date parsing and to avoid compatibility issues with Safari.

@rtivital rtivital merged commit 54518aa into mantinedev:master Feb 2, 2025
1 check passed
@rtivital
Copy link
Member

rtivital commented Feb 2, 2025

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Typing more than 4 numbers in DateInput component freezes the page on Safari
2 participants