Skip to content

Fix #6298: 🐛 Allow Enter key selection when selected is null#6300

Open
balajis-qb wants to merge 1 commit into
Hacker0x01:mainfrom
qburst:issue-6298/fix/year-picker-enter-null-selection
Open

Fix #6298: 🐛 Allow Enter key selection when selected is null#6300
balajis-qb wants to merge 1 commit into
Hacker0x01:mainfrom
qburst:issue-6298/fix/year-picker-enter-null-selection

Conversation

@balajis-qb

@balajis-qb balajis-qb commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Description

Linked issue: #6298


Problem

In YearPicker (showYearPicker), pressing Enter does not select a year when selected is null or undefined.

This is caused by an early return in onYearKeyDown (src/year.tsx):

if (this.props.selected == null) {
  break;
}

This prevents keyboard-based selection entirely when no initial value is set.

The behavior is inconsistent with:

  • Mouse selection (works correctly)
  • Default DatePicker and MonthPicker (keyboard works even with null selection)

Changes

  • Removed the selected == null guard from Enter key handling
  • Enabled selection based on the currently focused/preselected year
  • Updated test cases to reflect expected behavior
  • Removed/adjusted test enforcing no selection when selected is null

Behavior Changes

  • ✅ Enter key now selects a year even when selected is initially null
  • ✅ Keyboard and mouse interactions are now consistent
  • ✅ Behavior aligned with other picker modes
  • ⚠️ Existing tests expecting no selection on null selected are updated

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.

YearPicker prevented selection via Enter key when `selected` was null
due to an early return in `onYearKeyDown`.

This caused inconsistent behavior compared to:
- Mouse selection (which worked)
- Other picker modes (day/month)

Removed the unnecessary guard and allowed selection based on the
currently focused/preselected year.

Also updated tests that incorrectly enforced the previous behavior.

Closes Hacker0x01#6298
@codecov

codecov Bot commented Jun 29, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.31%. Comparing base (548a1f3) to head (8008f4e).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6300      +/-   ##
==========================================
+ Coverage   99.29%   99.31%   +0.02%     
==========================================
  Files          30       30              
  Lines        3822     3820       -2     
  Branches     1648     1664      +16     
==========================================
- Hits         3795     3794       -1     
+ Misses         26       25       -1     
  Partials        1        1              

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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.

1 participant