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 #4446: ✨ Added support for up and down arrow key movement in the year picker #4698

Conversation

balajis-qb
Copy link

Description

Linked issue: #4446

Problem
The Year Picker doesn't support the up and down key navigation like the month picker and the date picker.

Changes
This PR adds support for updating the selected year in the year picker using the up and down arrow keys. It also blocks the default page movement on the press of arrow keys.

Contribution checklist

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

… of the date picker

- Prevent the default scroll movement when the arrow key is pressed

Closes Hacker0x01#4446
@balajis-qb balajis-qb force-pushed the issue-4446/fix/support-up-down-key-navigation-for-year-picker branch from 8a1ae17 to 01dbc14 Compare April 16, 2024 11:07
Copy link

codecov bot commented Apr 16, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 97.12%. Comparing base (4500100) to head (01dbc14).
Report is 21 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4698      +/-   ##
==========================================
+ Coverage   97.00%   97.12%   +0.12%     
==========================================
  Files          28       28              
  Lines        2641     2682      +41     
  Branches     1119     1149      +30     
==========================================
+ Hits         2562     2605      +43     
+ Misses         79       77       -2     

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

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.

@balajis-qb you can click here to see the review status or cancel the code review job - or - cancel by adding [!pr] to the title of the pull request.

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

+ 154
- 5

59% JavaScript (tests)
41% JavaScript

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.

This improvement looks good to me. It mirrors the approach taken in day.jsx and month.jsx for handling "ArrowUp" and "ArrowDown". The tests are well thought-out and cover a variety of cases. I don't see any issues here.

Thanks for taking care of this!

Image of Ryan Ryan


Reviewed with ❤️ by PullRequest

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.

The change looks good - good job adding tests for the new logic.

Image of Jacques Jacques


Reviewed with ❤️ by PullRequest

if (key !== "Tab") {
// preventDefault on tab event blocks focus change
e.preventDefault();
}

if (!this.props.disabledKeyboardNavigation) {
switch (key) {
Copy link

Choose a reason for hiding this comment

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

ISSUE: default-case (Severity: Medium)
Expected a default case.

Remediation:
A default case (maybe with an exception) would be a welcome addition.

🤖 powered by PullRequest Automation 👋 verified by Jacques

Copy link
Author

@balajis-qb balajis-qb Apr 17, 2024

Choose a reason for hiding this comment

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

I don't think we need a default case in this code block. If the pressed key is Tab, then we're not blocking the default operation like month picker, else we're blocking the default behaviour just to prevent the outside container to auto-scroll on arrow key press. Let me know if you need any more changes.

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 reviewed the updates made to #4698 since our last review was posted. This includes comments that have been posted by non-PullRequest reviewers. No further issues were found.

Reviewed by:

Image of Jacques Jacques

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