react-spectrum icon indicating copy to clipboard operation
react-spectrum copied to clipboard

Allow entering leading zeroes into DateSegment.

Open adriantrunzo opened this issue 4 months ago โ€ข 3 comments

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

adriantrunzo avatar Mar 05 '24 02:03 adriantrunzo