Skip to content

Conversation

ftrdzputrap
Copy link
Contributor

I have an issue where, after typing the year and pressing Enter in the customInput field of React Datepicker, the value is automatically formatted when I delete it.

I'm handling the issue by blurring the field when Enter or Escape is pressed, and ensuring the selected value is preserved.

…custom input results in the first value being incorrectly formatted as '2001'.
Copy link

@pullrequest pullrequest bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ This pull request was sent to the PullRequest network for review. Expert reviewers are now being matched to your request based on the code's requirements. Stay tuned!

What to expect from this code review:
  • Comments posted to any areas of potential concern or improvement.
  • Detailed feedback or actions needed to resolve issues that are found.
  • Turnaround times vary, but we aim to be swift.

@ftrdzputrap you can click here to see the review status or cancel the code review job.

Copy link

@pullrequest pullrequest bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PullRequest Breakdown

Reviewable lines of change

+ 2
- 0

100% TSX

Type of change

Fix - These changes are likely to be fixing a bug or issue.

Copy link

@pullrequest pullrequest bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It may be worth switching from casting to a type guard (if (event.target instanceof HTMLInputElement) { ... }) and handling the case where that isn't true, in order to help avoid future bugs. Other than that, this seems pretty straightforward and looks good to me.

Image of Ryan Lester <@buu700> Ryan Lester <@buu700>


Reviewed with ❤️ by PullRequest

@ftrdzputrap
Copy link
Contributor Author

It may be worth switching from casting to a type guard (if (event.target instanceof HTMLInputElement) { ... }) and handling the case where that isn't true, in order to help avoid future bugs. Other than that, this seems pretty straightforward and looks good to me.

Image of Ryan Lester <@buu700> Ryan Lester <@buu700>

Reviewed with ❤️ by PullRequest

so i must handle this event using instanceof HTMLInputElement to get approval? or is there another way?

Copy link

@pullrequest pullrequest bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It may be worth switching from casting to a type guard (if (event.target instanceof HTMLInputElement) { ... }) and handling the case where that isn't true, in order to help avoid future bugs. Other than that, this seems pretty straightforward and looks good to me.

Reviewed with ❤️ by PullRequest

so i must handle this event using instanceof HTMLInputElement to get approval? or is there another way?

It's just a suggestion that may help make the code more robust, but ultimately it's up to you. If you prefer to use casting and already know for sure that the element in question is an input, that seems fine too.

Image of Ryan Lester <@buu700> Ryan Lester <@buu700>

Copy link

codecov bot commented Jan 5, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.92%. Comparing base (407051c) to head (876b253).
Report is 10 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #5292   +/-   ##
=======================================
  Coverage   96.92%   96.92%           
=======================================
  Files          29       29           
  Lines        3377     3379    +2     
  Branches     1400     1417   +17     
=======================================
+ Hits         3273     3275    +2     
+ Misses        104      102    -2     
- Partials        0        2    +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@martijnrusschen martijnrusschen merged commit 3be822e into Hacker0x01:main Jan 5, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants