fix: Change onMouseXXX event to onPointerXXX event
Thank you for allowing us to use your wonderful library.
I found a bug when using the selectsRange props.
When I select startDate and then select a date before that date, I get the react-datepicker__day--in-selecting-range style for a moment.
This occurs on touch devices and on the desktop Chrome touch device simulation.
It also seems to occur more noticeably when using monthsShown props and many calendars in a row.
I think that onPointerXXX events should be used rather than onMouseXXX events to more accurately capture events on touch devices.
(By using onPointerXXX events, the earlier decrease no longer occurs.)
Codecov Report
Attention: Patch coverage is 85.71429% with 4 lines in your changes are missing coverage. Please review.
Project coverage is 95.51%. Comparing base (
5f20755) to head (bf7f353).
| Files | Patch % | Lines |
|---|---|---|
| src/month.jsx | 66.66% | 4 Missing :warning: |
Additional details and impacted files
@@ Coverage Diff @@
## main #4542 +/- ##
=======================================
Coverage 95.51% 95.51%
=======================================
Files 29 29
Lines 2566 2566
Branches 1053 1053
=======================================
Hits 2451 2451
Misses 115 115
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
thanks for the review.
This change looks good to me by using
pointerevent to replacemouseevents. The only concern I have is regarding legacy browser/device compatibility/support.
My only concern with this PR is just that it seems to be changing the existing interface. Doing so would likely require a release with a version bump to the major version. My suggestion is to instead make these changes backward-compatible by maintaining the existing interface.
Thank you for your feedback on legacy browser support and backward compatibility of props.
For example, what do you think of the policy of adding usePointerEvents (bool) props (default: false) and binding the handler to onPointerXXX Event instead of onMouseXXX Event only if true?
It is also worth noting that switching to pointer events, specifically
pointerdownevents, can cause different behavior that is well-defined, but often not expected, compared tomousedownevents.This is referred to as implicit pointer capture and is covered in the spec.
This second point is not actionable for this PR, but should be kept in mind and referenced if any further migration to pointer-based events occurs.
Certainly we will need to be careful when adding new Event handlers in the future. However, the currently used onXXXEnter and onXXXLeave appear to work fine with Pointer.
I close this PR because I consider the other PR more useful. Thanks for taking your guys time to review!