♿️ Fix Calendar auto navigation regex issue for month navigation#6233
Open
balajis-qb wants to merge 1 commit intoHacker0x01:mainfrom
Open
♿️ Fix Calendar auto navigation regex issue for month navigation#6233balajis-qb wants to merge 1 commit intoHacker0x01:mainfrom
balajis-qb wants to merge 1 commit intoHacker0x01:mainfrom
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #6233 +/- ##
=======================================
Coverage 99.29% 99.29%
=======================================
Files 30 30
Lines 3822 3822
Branches 1648 1665 +17
=======================================
Hits 3795 3795
Misses 26 26
Partials 1 1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
- Fix the month matching regex to look for patterns like "03/", "/03", "03-", "-03" or standalone "03" at start - Avoid the optional matching of month pattern within year pattern - No longer matches the “03” embedded in a year like “2003”. - Added tests to ensure correct behavior for various month patterns, including edge cases with boundaries and reference dates. - Ensured fallback to the current month when only a year is provided without a reference date. Closes Hacker0x01#6214
a225f9a to
8cf6098
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Linked issue: #6214
Problem
As mentioned in the attached issue, we have an issue with the auto navigation of calendar popup while typing date manually in the date input. Basically we're navigating to the month based on the year's last two digit if we didn't provide a month. E.g. If we enter
2023as a date input value, instead of navigating toJan 1, 2023, it's navigating toMarch 2023. Basically we're takingMarchfrom 2023.This issue is because to match the month we used a regex pattern
/(?:^|[/\-\s])?(0?[1-9]|1[0-2])(?:[/\-\s]|$)/. Here the left boundary group was optional (...?), it could match a month inside other digits. Example: in "2003", it matched the trailing "03" since:Left: optional boundary allowed “no boundary”
Right:
$satisfied the end conditionChanges
/(?:^|[/\-\s])(0?[1-9]|1[0-2])(?:[/\-\s]|$)/It still matches an expected months in inputs like "03/", "/03", "03-", "-03", and standalone "03" at the start. But no longer matches the “03” embedded in a year like “2003”.
Note:
@martijnrusschen In the attached ticket, @floriancargoet mentioned if we just provide an year, it should navigate to January of that year. But in our code, if we didn't provide any month, we default that to current month. So, if the current date is
Feb 2, 2026and if the user enters just2003, it'll navigate toFeb 2003and notJan 2003. I shared the corresponding code snippet for your reference.But the issue won't be resolved on updating the above shared code alone, as we're passing the
preSelectedDateas a value forrefDateinparseDateForNavigation. and we default thepreSelectedDateto current date. If we need to defaultJanuarywe need an update in the other files also.Contribution checklist