react-datepicker icon indicating copy to clipboard operation
react-datepicker copied to clipboard

fix: refactor `DatePicker` component to handle `onChange` callback pr…

Open nmpavel opened this issue 1 year ago • 1 comments


name: Pull Request about: Create a pull request to improve this repository title: "Refactor DatePicker Component for Improved onChange Handling" labels: "" assignees: ""

Description

Linked issue: #5044

Problem The DatePicker component had redundant ternary operations for handling the onChange callback, and default onChange implementations were not necessary. This led to potential bugs and unnecessary complexity in the component’s behavior.

Changes Replaced ternary operations with optional chaining for better readability and functionality. Removed the default onChange implementation that was redundant and not used effectively. Updated handling of onChange and other props to ensure correct behavior.

Screenshots

To reviewers

Please review the changes to ensure that the DatePicker component now handles the onChange callback correctly and that the code is clean and well-tested. Feedback on the updated behavior and any edge cases is appreciated.

Contribution checklist

  • [ Yes] I have followed the contributing guidelines.
  • [ No] I have added sufficient test coverage for my changes.
  • [ Yes] I have formatted my code with Prettier and checked for linting issues with ESLint for code readability.

nmpavel avatar Aug 29 '24 18:08 nmpavel

Can you look into the merge conflict?

martijnrusschen avatar Aug 29 '24 19:08 martijnrusschen

This is a significant readability improvement; bravo! The dropping of the (empty) default func DatePicker.defaultProps.onChange is especially helpful. Without major logic changes, I presume the existing test coverage is still passing. Looks solid.

Image of Dylan F Dylan F

Reviewed with ❤️ by PullRequest

THank you very much for your support ,it's really inspirational

nmpavel avatar Aug 30 '24 12:08 nmpavel

Can you look into the merge conflict?

done

nmpavel avatar Aug 30 '24 13:08 nmpavel

This might be a duplicate of #5045 (great minds think alike!) that was merged very recently. After your merge commit, the diff looks empty.

laug avatar Aug 30 '24 14:08 laug

yes this seems unnecessary, please confirm this is indeed what's left over.

martijnrusschen avatar Aug 30 '24 18:08 martijnrusschen

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 96.85%. Comparing base (c834746) to head (fb72ae6). Report is 26 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #5061   +/-   ##
=======================================
  Coverage   96.85%   96.85%           
=======================================
  Files          29       29           
  Lines        3343     3343           
  Branches     1390     1390           
=======================================
  Hits         3238     3238           
  Misses        105      105           

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov[bot] avatar Aug 30 '24 18:08 codecov[bot]