react-component / react-component/picker
DayJs time picker strange behavior
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 304
- Forks
- 345
- Avg merge
- 2d 7h
- Merged PRs (30d)
- 7
Description
Following ant design directive to generate picker from DayJs, here is a sandbox: https://codesandbox.io/s/sparkling-silence-i430q
Try to type 10:10:1 in the input field and it is replaced by 10:10:01. So we cannot input 10:10:10 using the text input.
I think it is something related to the fact that 10:10:0 is considered valide from DayJs perspective and the corresponding time is 10:10:00. Maybe rc-picker should wait for the final input before parsing with dayjs?
After further investigation, dayjs has an open for strict parsing that should be used:
dayjs("10:10:1", "HH:mm:ss", null, true) // Invalid date
dayjs("10:10:1", "HH:mm:ss") // Valid but false as it resolved to 10:10:01
We could get rid of this problem at this line
https://github.com/react-component/picker/blob/234dd2a2659effad08a8e65bfd15f3c8d8bdfbd5/src/generate/dayjs.ts#L118
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the behavior in the linked CodeSandbox by typing 10:10:1, then inspect src/generate/dayjs.ts around line 118. Compare the documented strict and non-strict parsing behavior, and verify that typing 10:10:10 through the text input no longer changes the intermediate value unexpectedly.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- react, typescript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100