arqex / react-datetime

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

Fix 'last day of prev month' selection #805

Open katiepeters opened 2 years ago

katiepeters commented 2 years ago

Description

Fix 'last day of prev month' date selection in DateTime's _updateDate method (fixes #804)

Motivation and Context

Inside DateTime's _updateDate method, setting the data-value before the month/year causes unexpected behavior when a user selects the last day of the previous month. Switching the order resolves the issue.

Checklist

[x ] I have not included any built dist files (us maintainers do that prior to a new release)
[x ] I have added tests covering my changes
[x ] 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
katiepeters commented 2 years ago

@arqex Any reason why this bug hasn't been fixed yet? I saw that this problem has existed, at least as far back as May. Hopefully this can be resolved in the near future.

tom-mi commented 2 years ago

Thanks for providing this fix! (for now we'll apply it to our fork until it is merged) I have some issues with the snapshot test you changed though, I believe the changes in the snapshot tests caused by timezone differences. On my machine (Europe/Berlin) the old version still works, c1c82ac7639f99cb333bf2720880d0aff3f1a66b breaks it for me. The CI seems to run with Europe/Stockholm (https://github.com/tom-mi/react-datetime/blob/master/.travis.yml#L12)

ShaiGilboa commented 2 years ago

issue persists with latest version :(

bhavinzwt commented 1 year ago

Yes, issue persist in the latest version

Macy6 commented 1 year ago

The issue still persists with the latest version, any updates? :(

Thanks for providing this fix! (for now we'll apply it to our fork until it is merged) I have some issues with the snapshot test you changed though, I believe the changes in the snapshot tests caused by timezone differences. On my machine (Europe/Berlin) the old version still works, c1c82ac breaks it for me. The CI seems to run with Europe/Stockholm (https://github.com/tom-mi/react-datetime/blob/master/.travis.yml#L12)