Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #4483: Enable onKeyDown handler for the month picker view and the year picker view #4533

Conversation

balajis-qb
Copy link

Closes #4483

Description
This PR addresses the missing event handling to handle the key-press event for the month picker and the year picker. For the Year Picker component, I added onKeyDown and mapped it to the corresponding prop. However, the MonthPicker (month.jsx) is already receiving onKeyDown event, but that was mapped to the handler handleOnDayKeyDown which is the handler specifically we're using on day.jsx. In month.jsx we're not directly using it, but passing that to the Week component. Hence for the month.jsx alone, I didn't change any of its current behavior, and I added a new prop named handleOnMonthKeyDown which is linked to the onKeyDown event handler we pass from the DatePicker component. So users can still use onKeyDown itself for any datepicker view (day/month/year), but internally month.jsx alone is handling it via handleOnMonthKeyDown.

Changes Made

  • Updated Year picker and Month picker to handle the onKeyDown event.
  • Updated the corresponding test cases.

Balaji Sridharan added 2 commits February 25, 2024 22:35
Used `handleOnMonthKeyDown` for MonthPicker component to handle Key down events as the `handleOnKeyDown` prop was linked with `handleOnDayKeyDown` (& passed to the Week component)
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.


@balajis-qb 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

+ 61
- 0

84% JavaScript (tests)
16% JavaScript

Type of change

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

Copy link

codecov bot commented Feb 26, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.45%. Comparing base (20bb47c) to head (6b82aaf).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4533   +/-   ##
=======================================
  Coverage   95.45%   95.45%           
=======================================
  Files          29       29           
  Lines        2530     2533    +3     
  Branches     1037     1039    +2     
=======================================
+ Hits         2415     2418    +3     
  Misses        115      115           

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

onKeyDown={onKeyDownSpy}
/>,
);
TestUtils.Simulate.focus(ReactDOM.findDOMNode(datePicker.input));
Copy link
Member

Choose a reason for hiding this comment

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

I believe this is deprecated behavior. Can you use the new RTL library?

Copy link
Author

Choose a reason for hiding this comment

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

Updated

);
TestUtils.Simulate.focus(ReactDOM.findDOMNode(datePicker.input));

const month = TestUtils.findRenderedDOMComponentWithClass(
Copy link
Member

Choose a reason for hiding this comment

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

Same

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.

Great start here. I don't have any further notes beyond the comments left by martijnrusschen.

Image of Graham C Graham C


Reviewed with ❤️ by PullRequest

@martijnrusschen
Copy link
Member

Thanks for the fix!

@martijnrusschen martijnrusschen merged commit 89249a5 into Hacker0x01:main Feb 26, 2024
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.

onKeyDown function is not triggered in Month and Year Pickers.
2 participants