Skip to content

♿️ Fix Calendar auto navigation regex issue for month navigation#6233

Open
balajis-qb wants to merge 1 commit intoHacker0x01:mainfrom
qburst:issue-6214/fix/auto-navigation
Open

♿️ Fix Calendar auto navigation regex issue for month navigation#6233
balajis-qb wants to merge 1 commit intoHacker0x01:mainfrom
qburst:issue-6214/fix/auto-navigation

Conversation

@balajis-qb
Copy link
Contributor

@balajis-qb balajis-qb commented Feb 2, 2026

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 2023 as a date input value, instead of navigating to Jan 1, 2023, it's navigating to March 2023. Basically we're taking March from 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 condition

Changes

  • Require a real left boundary (start or delimiter) so months aren’t matched inside numbers:
  • Changed to: /(?:^|[/\-\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, 2026 and if the user enters just 2003, it'll navigate to Feb 2003 and not Jan 2003. I shared the corresponding code snippet for your reference.

image

But the issue won't be resolved on updating the above shared code alone, as we're passing the preSelectedDate as a value for refDate in parseDateForNavigation. and we default the preSelectedDate to current date. If we need to default January we need an update in the other files also.

image image

Contribution checklist

  • I have followed the contributing guidelines.
  • I have added sufficient test coverage for my changes.
  • I have formatted my code with Prettier and checked for linting issues with ESLint for code readability.

@codecov
Copy link

codecov bot commented Feb 2, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.29%. Comparing base (548a1f3) to head (8cf6098).

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

- 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
@balajis-qb balajis-qb force-pushed the issue-6214/fix/auto-navigation branch from a225f9a to 8cf6098 Compare February 2, 2026 10:34
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.

1 participant