♿️ Fix Calendar auto navigation regex issue for month navigation #76
+47
−1
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: Hacker0x01#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”.
Contribution checklist