TimeField resets `dayPeriod` segment when `hour` value is deleted
Provide a general summary of the issue here
For TimeField values greater than or equal to 12, clearing the hour segment input causes the dayPeriod segment value to flip from "PM" to "AM".
π€ Expected Behavior?
Each segment of a TimeField can be edited in place, and modifying the value of one segment input does not alter the value of the others, eg. clearing an hour value does not cause dayPeriod to change from "PM" to "AM" or vice-versa.
π― Current Behavior
- when a
TimeFieldvalue includes an hour >= 12, and - the hour segment has focus, and
- the user presses the delete key to clear the hour value
β¦the dayPeriod segment changes from "PM" to "AM"
π Possible Solution
No response
π¦ Context
No response
π₯οΈ Steps to Reproduce
- enter a time with an hour greater than or equal to 12 in a
TimeField- eg. on component documentation example, type "6:45 PM"
- move focus to the hour segment
- press delete
https://github.com/user-attachments/assets/44b47bfd-3e4c-464a-8915-628604419039
Version
What browsers are you seeing the problem on?
Chrome
If other, please specify.
also in Safari
What operating system are you using?
macOS 14.5
π§’ Your Company/Team
No response
π· Tracking Issue
No response
We may be able to implement this by adding another check here that is along the lines of the following (still needs more testing)
} else if (part === 'hour' && 'hour' in displayValue && displayValue.hour >= 12 && validSegments.dayPeriod) {
value = displayValue.set({hour: placeholder['hour'] + 12});
}
Hi @LFDanLu,
I would like to work on this issue. Could you please assign it to me or let me know if there are any specific requirements or guidelines I should follow?
Thank you!
Sure go for it! I would make sure to read through https://react-spectrum.adobe.com/contribute.html#contribute first. Other than that, feel free to reach out if you have any questions/concerns.
Hey @LFDanLu,
I noticed there was some activity on this issue, but it looks like it's still open/unassigned. Could I possibly work on this, or is it no longer available? Also would appreciate any advice if the issue is free to work on!
Thanks!
@charlotte-whiting Sure, go for it! I believe the comment still applies, so you can give that a shot and test locally to make sure it still does. As mentioned above as well, be sure to read through https://react-spectrum.adobe.com/contribute.html#contribute first!
thanks for this fix @charlotte-whiting !