Skip to content

Conversation

@balajis-qb
Copy link
Collaborator

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

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 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”.

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.

- 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.

2 participants