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

Add the option to select DateField type #1099

Closed
vcardins opened this issue Mar 31, 2022 · 8 comments · Fixed by #1103
Closed

Add the option to select DateField type #1099

vcardins opened this issue Mar 31, 2022 · 8 comments · Fixed by #1103
Assignees
Labels
Type: Feature New features and feature requests
Milestone

Comments

@vcardins
Copy link
Contributor

Currently, there is only the option to select a date and time on the DateField component.
https://github.com/vazco/uniforms/blob/master/packages/uniforms-material/src/DateField.tsx#L61

Maybe the type prop could be variable even if its default value is "datetime-local"

@wadamek65
Copy link
Contributor

Hi @vcardins , thanks for the issue report.

I agree with you and I think it would make sense to be able to handle the date type. Other types probably cannot be supported as they would break the functionality of the field if they were used.

Just to make sure - is date indeed the type that you would like to pass or do you have a different use case?

@wadamek65 wadamek65 self-assigned this Mar 31, 2022
@wadamek65 wadamek65 added the Type: Feature New features and feature requests label Mar 31, 2022
@vcardins
Copy link
Contributor Author

@wadamek65 Thanks for the quick reply. Initially, the date is the only use case that I need at the moment, but whichever types are possible would make it more flexible.
Thank you!

@radekmie
Copy link
Contributor

The only problem with incorporating more type variants is that we'd have to cover them in the value as well (here), as different types require different formats. We may implement it at some point, but I'd still recommend a custom date picker for better UX and browser compatibility.

@vcardins
Copy link
Contributor Author

I see. Could it then cover just datetime-local and date types? I believe that in the majority of the use cases only date is needed. Thanks!!

@vcardins
Copy link
Contributor Author

Hey, @radekmie it was not clear, should we expect that the type date will be added?

@radekmie
Copy link
Contributor

radekmie commented Apr 1, 2022

We've discussed it internally and we're willing to add support for type="date" as well, but there's no high priority for that. If you'd like to give it a shot, feel free to do so!

Things to do:

  • Handle value formatting differently, based on type.
    • I think that something like type === 'date' ? type : 'datetime-local' would be fine; type alone is a uniforms prop (e.g., Date) so we cannot use it directly.
  • Add tests.
    • Check if onChange works (it's probably fine as it is now).
    • Check if value formatting works.

@vcardins
Copy link
Contributor Author

vcardins commented Apr 1, 2022

Thanks, @radekmie. I'll work on that!

@vcardins
Copy link
Contributor Author

vcardins commented Apr 1, 2022

@radekmie Please, I'd appreciate your review on the PR #1103

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Feature New features and feature requests
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants