Skip to content

fix(pickers): auto-scroll year picker to active year, add month grid, and fix local date parsing - #172

Merged
treeder merged 3 commits into
mainfrom
fix/date-picker-year-and-month-selection
Dec 4, 2026
Merged

treeder merged 3 commits into
mainfrom
fix/date-picker-year-and-month-selection

Conversation

@treeder

@treeder treeder commented Dec 4, 2026

Copy link
Copy Markdown
Member

Summary

Fixes the root-cause UX and date-handling issues in where opening the year selector always started 100 years in the past (currentYear - 100, e.g., 1926) and required manual scrolling through a single-column list.

Changes

  • pickers/date-picker.js:
    • Switched .year-list to a Material Design 3 3-column grid (grid-template-columns: repeat(3, 1fr)) with overscroll-behavior: contain and scroll-initial-target: nearest on .year.selected, plus deterministic centering via .year-list.scrollTop (with instant scrollIntoView fallback) whenever year view opens.
    • Added a direct Month selector button and 3×4 month grid (Jan–Dec) alongside the Year selector button so users can jump directly to any month or year in 2 clicks.
    • Fixed YYYY-MM-DD parsing in updated() and
      enderHeader() to parse local calendar dates instead of UTC midnight (preventing off-by-one day/month/year shifts in UTC-negative timezones).
    • Prevented day-of-month overflow in prevMonth(),
      extMonth(), selectMonth(), and selectYear() (e.g., navigating back from Mar 31 now lands on Feb instead of Mar 3).
    • Respected min/max bounds in _getYearRange() and isMonthDisabled(), and upgraded day/month/year/period controls to semantic elements.
  • pickers/datetime-picker-dialog.js:
    • Calls
      esetView(this._date) on child whenever the dialog opens so reopening starts cleanly on the day calendar for the current value.
  • ** ext/text-field.js**:
    • Added -webkit-appearance: none; appearance: none; alongside display: none on .input::-webkit-calendar-picker-indicator to prevent duplicate calendar icons, and guarded openPickerDialog() when disabled or
      eadOnly.
  • ** ests/date_picker_test.js**:
    • Added 9 unit tests covering styles, timezone-safe parsing, centered year-list scrolling & fallback, month/year switching, month-end overflow safety, min/max bounds, dialog view reset, and disabled text-field guard.

Verification

  • Ran
    pm test — all 46 tests across 7 suites pass.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

📋 Review Summary

This PR enhances md-date-picker with separate month and year selector views, fixes UTC off-by-one date parsing and month-rollover bugs, and adds automatic scroll-centring for the selected year. It also resets the child date picker view when md-datetime-picker-dialog opens, blocks openPickerDialog() on disabled or read-only md-text-field instances while hiding the WebKit native calendar indicator, and adds comprehensive unit tests in tests/date_picker_test.js.

🔍 General Feedback

  • Good fix for local YYYY-MM-DD parsing in _parseDate() and day-of-month rollover avoidance in prevMonth(), nextMonth(), selectMonth(), and selectYear().
  • Replacing clickable <div> elements with native <button type="button"> elements, aria-pressed states, and :focus-visible outlines noticeably improves keyboard and screen reader accessibility.
  • The new unit tests in tests/date_picker_test.js follow the existing node:test conventions from tests/dialog_test.js and verify both CSS rules and runtime behaviour cleanly.
📊 Token Usage & Cost Efficiency
Metric Value
Input Tokens (uncached) 3,347
Input Tokens (cached) 119,189 (⚡ 97.3% cached)
Thinking / Reasoning Tokens 11,392
Output Tokens 1,187
Dynamic Context Selection Tokens 3,395
Pre-Flight Router Tokens 7,653
Pre-Flight Routing standard -> thinking high; dev docs gated off; skills: none
Total Session Tokens 146,163
Cost (uncached input) $0.0050
Cost (cached input) $0.0089
Cost (thinking / reasoning) $0.0854
Cost (response output) $0.0089
Cost (context selection) $0.0094
Cost (pre-flight router) $0.0008
Estimated Total Cost $0.1185

Gemini 4 Hydrogen: standard tier, global endpoint; regional endpoints are 10% higher.
Cache reads are priced here, but context-cache STORAGE, where the model charges for it separately per token-hour, is not included, so the figure can run slightly low.

Comment thread pickers/date-picker.js Resolved
Comment thread pickers/date-picker.js Resolved
Comment thread pickers/date-picker.js Resolved

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

📋 Review Summary

This pull request enhances <md-date-picker>, <md-datetime-picker-dialog>, and <md-text-field> with dedicated month and year selection views, local YYYY-MM-DD date parsing without UTC timezone shifts, automatic scroll centring for the selected year, min/max bounds handling, and suppression of the native WebKit calendar indicator on date inputs. The prior review feedback regarding month hover specificity, accessible aria-label values on period selectors, and single-sided min/max year range clamping has been addressed and verified in the new tests/date_picker_test.js suite. Overall, the changes meaningfully improve usability, accessibility, and test coverage, with one medium edge case around datetime-local min/max strings in isMonthDisabled and two minor UX/styling improvements noted inline.

✅ Resolved Items from Prior Reviews

  • Added :not(.selected) to .month:hover:not(:disabled):not(.selected) in pickers/date-picker.js so hovering over the currently selected month preserves its selected background and contrast. (pickers/date-picker.js:535)
  • Updated the month and year period selector aria-label attributes to include the active month and year labels (Select month, ... and Select year, ...). (pickers/date-picker.js:141)
  • Clamped the unbounded side in _getYearRange() when only min or max is set beyond the default 100-year window, preventing inverted/out-of-bounds year ranges. (pickers/date-picker.js:247)

🔍 General Feedback

  • Good use of new Date(year, month - 1, day) validation in _parseDate() and first-of-month construction in prevMonth()/nextMonth() to avoid UTC off-by-one shifts and day-of-month overflow bugs (e.g. Jan 31 advancing to March).
  • Combining CSS scroll-initial-target: nearest with a _scrollSelectedYearIntoView() fallback ensures reliable year-list centring across browsers, and tests/date_picker_test.js thoroughly covers both layout paths and edge cases.
  • Resetting <md-date-picker> back to the day view whenever <md-datetime-picker-dialog> opens prevents stale month/year view state across repeated dialog openings.
📊 Token Usage & Cost Efficiency
Metric Value
Input Tokens (uncached) 2,411
Input Tokens (cached) 120,476 (⚡ 97.3% cached)
PR Comments History Tokens 936
Thinking / Reasoning Tokens 11,974
Output Tokens 1,451
Dynamic Context Selection Tokens 3,192
Pre-Flight Router Tokens 7,653
Pre-Flight Routing standard -> thinking high; dev docs gated off; skills: none
Total Session Tokens 148,093
Cost (uncached input) $0.0050
Cost (cached input) $0.0090
Cost (thinking / reasoning) $0.0898
Cost (response output) $0.0109
Cost (context selection) $0.0079
Cost (pre-flight router) $0.0008
Estimated Total Cost $0.1234

Gemini 4 Hydrogen: standard tier, global endpoint; regional endpoints are 10% higher.
Cache reads are priced here, but context-cache STORAGE, where the model charges for it separately per token-hour, is not included, so the figure can run slightly low.

Comment thread pickers/date-picker.js Resolved
Comment thread pickers/date-picker.js Resolved
Comment thread pickers/date-picker.js Resolved

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

📋 Review Summary

This PR enhances md-date-picker with dedicated month and year selection views, local YYYY-MM-DD date parsing to avoid UTC timezone shifts, 3-column grid layouts with automatic scroll centring for the selected year, and min/max bound clamping. It also updates md-datetime-picker-dialog to reset the child date picker to the day view upon opening, prevents md-text-field from opening the picker dialog when disabled or readOnly while hiding the native WebKit calendar indicator, and adds comprehensive unit tests in tests/date_picker_test.js.

✅ Resolved Items from Prior Reviews

  • Added :not(.selected) to the .month:hover:not(:disabled) selector in pickers/date-picker.js so hovering over the selected month preserves primary contrast. (pickers/date-picker.js:535)
  • Updated the month and year selector buttons' aria-label attributes in pickers/date-picker.js to include the currently displayed month and year. (pickers/date-picker.js:141)
  • Clamped the unbounded year boundary in _getYearRange() in pickers/date-picker.js when only max (or only min) is supplied outside the default 100-year window. (pickers/date-picker.js:247)
  • Normalised this.min and this.max via _parseDate() and formatDate() in isMonthDisabled() in pickers/date-picker.js so datetime-local bounds do not disable boundary months. (pickers/date-picker.js:354)
  • Clamped month within the bounded year's valid months inside selectYear() in pickers/date-picker.js when min or max constrains the selected year. (pickers/date-picker.js:317)
  • Updated .year-list padding to 4px in pickers/date-picker.js so :focus-visible outlines on outer grid columns are not clipped by the scroll container. (pickers/date-picker.js:562)

🔍 General Feedback

  • Good accessibility improvements in pickers/date-picker.js: converting day, month, year, and period-selector cells from <div> elements into semantic <button type="button"> elements with aria-pressed, aria-expanded, and :focus-visible outlines significantly improves keyboard navigation and screen-reader support.
  • The local YYYY-MM-DD parsing in _parseDate() and first-of-month construction in prevMonth()/nextMonth() cleanly prevent UTC off-by-one shifts and day-of-month overflow (such as 31 January jumping to March).
  • Combining progressive CSS scroll-initial-target: nearest with _scrollSelectedYearIntoView() provides reliable year centring across browsers.
📊 Token Usage & Cost Efficiency
Metric Value
Input Tokens (uncached) 1,635
Input Tokens (cached) 122,433 (⚡ 97.3% cached)
PR Comments History Tokens 1,719
Thinking / Reasoning Tokens 9,606
Output Tokens 993
Dynamic Context Selection Tokens 3,198
Pre-Flight Router Tokens 7,653
Pre-Flight Routing standard -> thinking high; dev docs gated off; skills: none
Total Session Tokens 147,237
Cost (uncached input) $0.0050
Cost (cached input) $0.0092
Cost (thinking / reasoning) $0.0720
Cost (response output) $0.0074
Cost (context selection) $0.0080
Cost (pre-flight router) $0.0008
Estimated Total Cost $0.1024

Gemini 4 Hydrogen: standard tier, global endpoint; regional endpoints are 10% higher.
Cache reads are priced here, but context-cache STORAGE, where the model charges for it separately per token-hour, is not included, so the figure can run slightly low.

Comment thread tests/date_picker_test.js
},
}
await field.openPickerDialog()
assert.equal(showed, false)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 The test description states that it verifies blocking the picker dialog when text-field is disabled or readOnly, but only field.disabled = true is currently exercised. Consider also asserting field.readOnly = true so both branches of the guard in openPickerDialog() are covered.

Suggested change
assert.equal(showed, false)
assert.equal(showed, false)
field.disabled = false
field.readOnly = true
await field.openPickerDialog()
assert.equal(showed, false)

@treeder
treeder merged commit db2f5cb into main Dec 4, 2026
1 check passed
@treeder
treeder deleted the fix/date-picker-year-and-month-selection branch December 4, 2026 21:38
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