Repository navigation
fix(pickers): auto-scroll year picker to active year, add month grid, and fix local date parsing - #172
Conversation
…fix local date parsing
There was a problem hiding this comment.
📋 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-DDparsing in_parseDate()and day-of-month rollover avoidance inprevMonth(),nextMonth(),selectMonth(), andselectYear(). - Replacing clickable
<div>elements with native<button type="button">elements,aria-pressedstates, and:focus-visibleoutlines noticeably improves keyboard and screen reader accessibility. - The new unit tests in
tests/date_picker_test.jsfollow the existingnode:testconventions fromtests/dialog_test.jsand 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.
… and extreme min/max bounds
There was a problem hiding this comment.
📋 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)inpickers/date-picker.jsso 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-labelattributes to include the active month and year labels (Select month, ...andSelect year, ...). (pickers/date-picker.js:141) - Clamped the unbounded side in
_getYearRange()when onlyminormaxis 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 inprevMonth()/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: nearestwith a_scrollSelectedYearIntoView()fallback ensures reliable year-list centring across browsers, andtests/date_picker_test.jsthoroughly 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.
…itch, and pad year-list
There was a problem hiding this comment.
📋 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 inpickers/date-picker.jsso hovering over the selected month preserves primary contrast. (pickers/date-picker.js:535) - Updated the month and year selector buttons'
aria-labelattributes inpickers/date-picker.jsto include the currently displayed month and year. (pickers/date-picker.js:141) - Clamped the unbounded year boundary in
_getYearRange()inpickers/date-picker.jswhen onlymax(or onlymin) is supplied outside the default 100-year window. (pickers/date-picker.js:247) - Normalised
this.minandthis.maxvia_parseDate()andformatDate()inisMonthDisabled()inpickers/date-picker.jssodatetime-localbounds do not disable boundary months. (pickers/date-picker.js:354) - Clamped
monthwithin the bounded year's valid months insideselectYear()inpickers/date-picker.jswhenminormaxconstrains the selected year. (pickers/date-picker.js:317) - Updated
.year-listpadding to4pxinpickers/date-picker.jsso:focus-visibleoutlines 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 witharia-pressed,aria-expanded, and:focus-visibleoutlines significantly improves keyboard navigation and screen-reader support. - The local
YYYY-MM-DDparsing in_parseDate()and first-of-month construction inprevMonth()/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: nearestwith_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.
| }, | ||
| } | ||
| await field.openPickerDialog() | ||
| assert.equal(showed, false) |
There was a problem hiding this comment.
🟢 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.
| assert.equal(showed, false) | |
| assert.equal(showed, false) | |
| field.disabled = false | |
| field.readOnly = true | |
| await field.openPickerDialog() | |
| assert.equal(showed, false) |
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
enderHeader() to parse local calendar dates instead of UTC midnight (preventing off-by-one day/month/year shifts in UTC-negative timezones).
extMonth(), selectMonth(), and selectYear() (e.g., navigating back from Mar 31 now lands on Feb instead of Mar 3).
esetView(this._date) on child whenever the dialog opens so reopening starts cleanly on the day calendar for the current value.
eadOnly.
Verification
pm test — all 46 tests across 7 suites pass.