arqex / react-datetime

A lightweight but complete datetime picker react component.
1.99k stars 872 forks source link

Fix issue with caret snapping to end on intial keyboard edits of controlled date picker #832

Closed aidando73 closed 1 year ago

aidando73 commented 2 years ago

Description

Eliminates use of callback on setState to call this.props.onChange which was causing an issue with caret position resetting when you initially keyboard edit a newly selected date (on a controlled date picker).

Motivation and Context

This fixes the issue #831

Keyboard edits to controlled datepicker is a very common use case. Currently for a date like 11/11/1988, if a user wants to change month 11 to month 9, when to replace month 11, the caret will snap to the end. This can get very annoying if a user needs to use the keyboard edits to quickly fix a date and they must do this many times throughout a session.

Checklist

[ x ] I have not included any built dist files (us maintainers do that prior to a new release)
[ ] I have added tests covering my changes
[ ] All new and existing tests pass
[ ] My changes required the documentation to be updated
  [ ] I have updated the documentation accordingly
  [ ] I have updated the TypeScript 1.8 type definitions accordingly
  [ ] I have updated the TypeScript 2.0+ type definitions accordingly
aidando73 commented 1 year ago

Closing this PR, just cleaning up my PRs. Let me know if you want me to reopen this PR @arqex