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

fix(datepicker): Parsing user input, use moment for custom formats, handle resize - FRONT-4643 #3668

Merged
merged 3 commits into from
Oct 14, 2024

Conversation

planctus
Copy link
Collaborator

@planctus planctus commented Oct 8, 2024

A bit of context:

  • We were showing dates in this format: DD-MM-YYYY but only if the user picked a day from the calendar, if a user tried to enter a valid date in the requested format instead the resulting date would have been screwed because pikaday was still parsing it using its default format.
  • So a parsing function has been added, if it's our default format we parse it directly to a string using DD-MM-YYYY, if it's a custom format we pass to moment.js the user input and see if returns a valid date in the chosen format.
  • Additionally a resize listener has been added, we customise the styles of the drowpdown in mobile we are now also resetting those styles if the user resizes the window.

To test this simply type a date in the datepicker, it should pick up the right date.
To test the custom formats you would need to play with the story, set the autoInit() to false and manually initialising the component with a custom format passed as an option.

Copy link

github-actions bot commented Oct 8, 2024

@github-actions github-actions bot temporarily deployed to pull request October 8, 2024 11:28 Inactive
@github-actions github-actions bot temporarily deployed to pull request October 8, 2024 11:40 Inactive
@planctus planctus marked this pull request as ready for review October 8, 2024 12:06
@github-actions github-actions bot temporarily deployed to pull request October 14, 2024 12:56 Inactive
@emeryro emeryro merged commit ee4a2cc into v4-dev Oct 14, 2024
7 checks passed
@emeryro emeryro deleted the FRONT-4643-Datepicker-user-input-format branch October 14, 2024 12:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants