react-spectrum
react-spectrum copied to clipboard
Allow entering leading zeroes into DateSegment.
Provide a general summary of the feature here
With any of the Date related components from React Aria Components -- DateField, DatePicker, DateRangePicker -- the user cannot enter leading zeroes. When the placeholder value shows 2 digits, like "mm", users can think that they have to enter both digits, but don't receive any feedback when entering leading zeroes.
๐ค Expected Behavior?
When focused on a month, day, or year date segment, provide feedback when a leading zero is entered by changing the segment value to "0" (or "00" when shouldForceLeadingZeroes is enabled). When the segment loses focus and still has a numeric value of zero, revert the segment to its previous value or the placeholder if no previous value.
๐ฏ Current Behavior
Pressing zero to enter a leading "0" as in month "03" provides no feedback:
https://github.com/adobe/react-spectrum/assets/1218900/69a8796f-3935-4a1e-abb5-de14ee7244ad
๐ Possible Solution
I haven't investigated any workarounds. The HTML date input shows feedback for entering zeroes by changing the value to "00". I recognize that keeping the zero value is troublesome since it's never a valid value (not even for year), which is why I suggest reverting any only zero values when the date segment loses focus.
Here's an example of using the HTML date input in Firefox and getting feedback when entering leading zeroes: https://github.com/adobe/react-spectrum/assets/1218900/167fa676-50b3-440e-a6aa-cba6501f8c5e
๐ฆ Context
While building a styled wrapper of DateRangePicker, some of the first feedback I received is that the keyboard access for entering dates is broken -- the placeholder shows "mm/dd/yyyy", but when you try to enter a leading zero nothing happens.
๐ป Examples
No response
๐งข Your Company/Team
No response
๐ท Tracking Issue
No response