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

feat(DateField): improve month segment behavior for invalid months starting with 1 #1560

Draft
wants to merge 8 commits into
base: v2
Choose a base branch
from

Conversation

acabreragnz
Copy link

Changes

  • Modified the month segment behavior in DateField to handle invalid months starting with 1 (13-19) more intuitively
  • When typing invalid months like 13-19:
  • Keeps 1 as the month value
  • Automatically uses the second digit as the initial value for the day segment
  • Moves focus to day segment

Example

When typing "13":

  • "1" remains as the month value
  • Focus moves to day segment
  • "3" becomes the initial value of the day

Why

This change improves user experience by making the input behavior more intuitive when users type invalid month numbers. Instead of discarding the first digit, it uses both digits meaningfully - preserving the valid part (1) for the month and using the second digit to pre-fill the day.

Testing

  • Type "13" - should keep "1" as month and move to day with "3"
  • Type "14" - should keep "1" as month and move to day with "4"
  • Type "10", "11", "12" - should work as before (valid months)
  • Type "2"-"9" - should work as before (single digit months)

@acabreragnz acabreragnz force-pushed the fix-ux-month-movement branch from ad0ee78 to 4021da8 Compare January 16, 2025 19:33
…arting with 1

When typing invalid months starting with 1 (13-19):
- Keeps 1 as the month value
- Automatically uses the second digit as the initial value for the day segment

For example, when typing "13":
- "1" remains as the month
- Moves to day segment
- "3" becomes the initial value of the day
@acabreragnz acabreragnz force-pushed the fix-ux-month-movement branch from 4021da8 to b29a011 Compare January 16, 2025 19:34
@epr3 epr3 self-requested a review January 17, 2025 06:31
Copy link
Collaborator

@epr3 epr3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @acabreragnz,

First of all, thank you for your contribution! 🚀

The feature is very good improvement to the UX, but I have one concern about it, namely if you change the locale to fr or any other locale which uses the dd/mm/yyyy format, it moves the focus on the year segment and updates the day which would be the desired behaviour.

You could add a check to see which is the next segment and/or maybe expand this functionality for the dd/mm/yyyy format and yyyy/mm/dd, the latter being used by locales such as zh.

@acabreragnz acabreragnz marked this pull request as draft January 17, 2025 15:54
@acabreragnz
Copy link
Author

acabreragnz commented Jan 20, 2025

@epr3 thank you for your feedback! the PR was not ready for review; it was my mistake for not setting it as a draft.

Currently, I'm finalizing the same behavior for transitioning from days to years in the en locale.
For instance, when typing the day 34 we should expect MM/3/4YYY instead of MM/4/YYYY.

Once this is complete, I will polish the code and implement all the changes you requested.

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