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

TimeField resets `dayPeriod` segment when `hour` value is deleted

Open dspnorman opened this issue 1 year ago β€’ 3 comments

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 TimeField value 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

[email protected]

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

dspnorman avatar Jul 29 '24 18:07 dspnorman

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});
      }

LFDanLu avatar Jul 30 '24 00:07 LFDanLu

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!

parthsali avatar Aug 20 '24 17:08 parthsali

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.

LFDanLu avatar Aug 20 '24 20:08 LFDanLu

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 avatar Nov 21 '24 06:11 charlotte-whiting

@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!

LFDanLu avatar Nov 21 '24 17:11 LFDanLu

thanks for this fix @charlotte-whiting !

dspnorman avatar Jan 29 '25 00:01 dspnorman