Skip to content

Conversation

@ChrisSmartGP
Copy link

@ChrisSmartGP ChrisSmartGP commented Oct 30, 2025

First up i'd just like to say thanks so much for all the work that has gone into this library :)

I've encountered an issue where setting the time does not work when 'pm' is set and the user tries to enter the values 10, 11 or 12 in the hour input.

When in a locale that uses 12 hour time format:

  • the updateHour method should have a max accepted value of 12
  • the internally represented time should convert back to 12 hour format before using the updateHour method. Not doing so will cause the method to return early
  • I added a method to determine the hourCycle from the locale but I think maybe this should just use the props.hourCycle. However props.hourCycle is undefined unless it is explicitly passed

(resolves #2262)

@zernonia
Copy link
Member

zernonia commented Nov 4, 2025

Yo @ChrisSmartGP ! Appreciate the PR, could you create a ticket and explain the issue with reproduction please? 🙏🏼

@ChrisSmartGP
Copy link
Author

@zernonia thanks for giving this some attention 🙏 have added an issue with reproduction #2262

@pkg-pr-new
Copy link

pkg-pr-new bot commented Nov 19, 2025

Open in StackBlitz

npm i https://pkg.pr.new/reka-ui@2254

commit: 78a64f0

@ChrisSmartGP
Copy link
Author

Hi @zernonia have you had a chance to look at this ?

Copy link
Collaborator

@sadeghbarati sadeghbarati left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @ChrisSmartGP, tested your StackBlitz with pkg.pr.new, it fixes the PM switch to AM problem, but
When I start from 1 to 12, the PM will change to AM.

Each time it reaches 12, it toggles between AM and PM.


The code from react-aria might help you here

https://github.com/adobe/react-spectrum/blob/main/packages/%40react-stately/datepicker/src/useDateFieldState.ts

@ChrisSmartGP
Copy link
Author

ChrisSmartGP commented Dec 8, 2025

@sadeghbarati thanks for acknowledging the fix; when using the arrow keys on the hour input it will cycle between am and pm which is great.

This fix is primarily aimed at stopping the picker from switching back to am when a user types a new value in the hour input.

Thanks for the link to adobe code; they have some handling for 12 hour time here. Reka's updateHour method is missing this and only considers 24 hour time. This PR updates it to handle 12 hour time aswell

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: TimeField hour input handling broken for 12 hour time

3 participants