-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
[pickers] New component: DateField
#5531
Comments
I think spectrum approach is more promising for this component. Instead of controlling the selection, they use dedicated It sounds easier to customize and to have screen readers About spliting
We've already got an issue to put date elements in the correct order according to localization #4756 A way to be reliable with the different libraries could be to define them as a combination of different properties:
|
Why is that ? For customization, Telerik approach allows users to very easily use there own input whereas in Spectrum, users need to customize a div to look like there input. For screen readers, I'm not very good on that topic. But I would expect a single input to be able to have some aria attribute so that the screen reader understands it's a date.
Do you have an approach that does not require to split the date ?
My POC supports order change, I parse the format string to determine where is the month / the day and the year.
Yes, I only support date-fns on the POC but it would clearly not work out of the box for other libraries.
Not sure to understand how the lines below differs from my current implementation.
|
About customization, I agree. I was thinking, about specific style for month/day but it 's not really an helpful customization About a11y my concern is to be able to say that the focus is on the month section of the date input, and when updating it only says the month updated, and not the full date.
Yes, you support orders provided by users, but not the order provided by the date library. From what I understand, libraries offer ways to display the month in multiple ways (1 digit, 2 digits, short name, full name, ...) with But the date localization includes also the way all those elements are mixed. Then they have special tokens for full-date, full-date-time, ... For example in the fullDate: "PP" |
We should be able to do the same thing as the But yes if I'm missing something and we can't do it, we could be totally stuck. |
I confirm that it does seem to work for |
And I see it's now possible to add this |
For Luxon it's a work in progress (I just tried to use there new method but I still have some issues), but yes it should work in the near future. Another concern I have about this format parsing (for both Telerik and Spectrum) is that I need to know that |
Not sure to understad. You need to know that You could get an array of options by formatting 12 dates with |
Because if it's a full letter month, I need to store the "query". We might have similar topics for years. |
Continuing the conversation from #5504 for more general customization options:
Seeing "month" written out gives me the expectation that I will be choosing a month written out (January, February, March, etc.), even though the input is looking for a number. Since dates and time can have so many different formats, it would be beneficial to be as clear as possible for the end user about the expected input. I was also thinking about the customization options and put together a basic prototype to explore customization. There are 2 flows: the standard Material components + a customized version with many style changes that I could imagine someone may want. This also brought up the options for how to show information that is expected, but hasn't been keyed in yet. I see we currently use zeroes, but maybe this is something that people would want to customize as well? |
I took a look at the mobile behavior of the field. The issues comes from the fact that on android I try to change the approach and use the I took a look at Telerik's DateInput behavior on Android, and it is exactly what I described above (it is impossible to enter a multi character value in a date section). So right now we do have a major problem when it comes to mobile usage of the I still have a few ideas to experiment:
|
@flaviendelangle Nitpick, but consider ignoring |
Yes, I was not using it but I tried just in case to see if it was working for Android |
@gerdadesign concerning the placeholder. I see two topics here
Spectrum and Telerik have the same behavior as we do today: only show the placeholder when the value is empty for this section and show the value of the section otherwise. I do agree that some of your proposals feels cleaner.
On that one, I went to the easiest content (the name of the section: Telerik uses the name of the section ( For Spectrum, they have different placeholder based on the section (code here). For this one, I think the spectrum behavior is a good baseline. |
Thank you for this resource! It looks great.
Just to clarify — was this intentional? 4 placeholder letters for a 2-numeral input? If so, why not 2 letters for 2 numerals? |
It has a small typo, I just meant to as far as I understand, Spectrum either does not support custom format for the year (that's very possible) or chose to keep its placeholder system as simple as possible with just one placeholder per type of section. |
Another thought. Here would be the visual output I think would appear with all solutions after pressing Approaches that don't work well in this scenario:
Approaches that work but not perfectly:
Approaches that work perfectly:
|
I do see zeroes a lot and it seems to be a common default! I would expect it to accept both |
Closing this one, the |
I am calling this component
DateField
like React Sectrum, some are calling itDateInput
like Telerik.The base idea is to have a basic component to enter dates without any view.
Here is a POC to see what's doable: #5504
Benchmark
Related components
Other field components
Most of the logic of this component can be used for future components like
DateTimeField
orDateRangeField
orTimeField
if relevant.Telerik did a single
DateInput
component that can act like aTimeInput
or aDateTimeInput
.The only use case where another component would be usefull is probably
DateRangeField
where the input format is inherently different.Usage with views
When used with views (for instance in
DatePicker
) one of the goal can be to make the view and the input parts as independent as possible to allows users to deeply override one of the two.For instance, replacing the
DateField
inDatePicker
with a custom one that has one input per section.Goals
Principle
The basic idea is to split a date into sections that will be editable independently.
For instance in the format
dd/MM/yyyy'
(date-fns format), we want to split into :dd
=> the dayMM
=> the monthyyyy
=> the yearWe will then be able to navigate across those sections with the left and right arrow keys and to edit the currently selected sections in several ways:
ArrowUp
/ArrowDown
to remove / add one unit to the sectionChallenges
Analyze a format token (i.e
MMMM
) and know if it targets a day, a month or a year)Maybe some date libraries expose this information.
Otherwise, it could probably be hard-coded in the adapter.
Release process
The idea is to work on this new component in parallel with the current pickers.
The process could look something like
Unstable_DateField
componentUnstable_DatePicker
component using theUnstable_DateField
as its input component instead of our currentPireDateInput
DateField
with the newUnstable_DateField
in some future majorThe text was updated successfully, but these errors were encountered: