Skip to content

fix(DatePicker-InputDate): Month only picker is introduced - #220

Open
atakanbayrak wants to merge 15 commits into
mainfrom
fix/day_picker_month_picker
Open

atakanbayrak wants to merge 15 commits into
mainfrom
fix/day_picker_month_picker

Conversation

@atakanbayrak

Copy link
Copy Markdown
Contributor

Description

Month only picker is introduced without creating stand alone component.

Type of Change

  • 🆕 New Component
  • ✨ Feature / Enhancement
  • 🐛 Bug Fix
  • 💥 Breaking Change
  • 📦 Build / Dependency / Docs Update
  • 🧹 Code Refactoring

Screenshots / Preview

Screenshot 2026-11-06 at 15 12 04

Checklist

  • Self-reviewed, no leftover logs or debug code
  • Uses design tokens — no hardcoded style values
  • Accessible (keyboard nav, ARIA, contrast)
  • Tests added/updated and passing
  • Storybook story added/updated

How to Test

page.tsx

@claude

claude Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @aktasmehmet's task in 31s —— View job


Review of #220: MonthPicker and YearPicker

I read the diff against origin/main and applied docs/review/general.md and docs/review/tests.md. The PR has no .scss changes and no migrated-component or token changes, so css.md, figma.md and design-tokens.md don't apply. No .Root rules are affected.

The branch now follows @aktasmehmet's suggestion. MonthPicker returns the month index (0 for January) and YearPicker returns the year. Neither has a day/month/year switcher. DatePicker reuses the extracted MonthGrid, YearGrid and useYearPage, so the markup and paging logic aren't duplicated. The pickerFormat and InputDate changes from the earlier iterations are gone from the diff, so the earlier review threads about them (isMonthOnly, pickerFormat defaults and tests, Exclude<…> repetition, onDateChange on a re-click) no longer apply.

Issues

  1. PR metadata is stale. The title (fix(DatePicker-InputDate): Month only picker is introduced), the description ("without creating stand alone component"), the "Bug Fix" checkbox and the release:patch label no longer match the change. The PR adds two public components and exports them from src/lib/index.ts. This should be a feat(MonthPicker, YearPicker): … PR with a minor release label. The "How to Test" page.tsx attachment probably tests the old pickerFormat approach too.

  2. MonthPicker.test.tsx, assertDefaults (tests.md §1). The // locale: English assertion isn't a prop default. locale has no default in the component, and the English text comes from useDateLocale. Drop it. The existing "should show the month names in the locale prop" test already covers the locale behavior. The variant and size assertions are correct and have their comments.

  3. DatePicker behavior change in YearSelector.tsx. Years used to be recomputed from pickerDate on every change. Now the page only moves when the year leaves the current page. This is better, because picking a year no longer shifts the grid, but it is a behavior change in the existing DatePicker. Please confirm it is intended. Also add or confirm a DatePicker test for "open the year view, go to the next page, pick a year, reopen", since the new tests only cover YearPicker.

Suggestions (non-blocking)

  • Both new components import DatePicker.module.scss and DatePicker/components/... through the @/components/DatePicker/... alias. This works, but it ties them to DatePicker internals. Consider moving the shared MonthGrid, YearGrid and useYearPage (and the related styles) into a shared folder, for example Motif/Pickers. Otherwise a later DatePicker refactor can break the standalone pickers.
  • Neither component fires onMonthChange or onYearChange when the already-selected value is clicked. This is tested, so it is a deliberate choice. A consumer that closes a popup on change will not close on a re-click, so document it in the prop JSDoc.
  • Add a fluid test, for example that the fluid class is applied to both the Picker and the dateSelector div.
  • YearPicker falls back to new Date().getFullYear() on every render when there is no value. That is fine here. It would be more predictable to compute it once, for example with useState(() => …).

Done well

  • Tests cover value changes, re-click, locale, paging and an out-of-page value.
  • Both components are registered in ComponentDefaultableProps.
  • displayName is set, PropsWithRef is used, and the code has no any or let.

@github-actions

github-actions Bot commented Nov 6, 2026 •

Copy link
Copy Markdown

Size Change: +1.21 kB (+0.43%)

Total Size: 285 kB

📦 View Changed
Filename Size Change
dist/index.cjs 142 kB +586 B (+0.41%)
dist/index.es.js 141 kB +626 B (+0.45%)
ℹ️ View Unchanged
Filename Size
dist/chunks/useToggle-1pe2WRaw.js 800 B
dist/chunks/useToggle-B6kbi656.cjs 769 B
dist/hooks.cjs 225 B
dist/hooks.es.js 219 B

compressed-size-action

}, [pickerDate, setPickerDate]);

const handleMonthClick = (month: number) => {
if (isMonthOnly) {

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.

Re @ZehranurC's note: the year → day jump isn't introduced by this PR. In day view Header.tsx:27 passes previousTab="day" to the year button when a month label is shown, and YearSelector.handleYearClick returns to previousTab. Changing it to year → month → day would be a behavior change to the default picker, so it's better as a separate change (or an explicit decision here).

Also, in month-only mode onDateChange only fires when the month changes. Clicking the already-selected month emits nothing, so a consumer that closes on onDateChange (e.g. InputDate) won't close.

Comment thread src/lib/components/DatePicker/types.ts Resolved
const handleMonthClick = (month: number) => {
if (isMonthOnly) {
const date = new Date(pickerDate.getFullYear(), month, 1);
selectedDate?.getTime() !== date.getTime() && onDateChange?.(date);

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.

Still open from the earlier review: clicking the already-selected month emits nothing, so InputDate (which calls hide() inside dateChangeHandler) stays open. In month-only mode there's no OK button flow to fall back on, and the user has made an explicit choice. The test "should not fire onDateChange when the already selected month is clicked again" locks this in.

Consider always calling onDateChange?.(date) in month-only mode (the InputDate handler already dedupes through applyChanges/state), or document the behavior. Also, cond && fn() as a statement is a lint-unfriendly pattern; prefer if.

@aktasmehmet aktasmehmet 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.

I was expecting something like "MonthPicker". This is still a datepicker without the days. You still have to choose a year to select a month.

We should create (or change) a picker to select only months (which should give reresult as the index on the month, like if january, then 0, and so on), and a year picker.

There should not be anything else, like switching between day-month-year selectors, etc.

Maybe current implementation is the one that is requested but it is no the right way of doing that.

In fact (we can discuss), what about creating seperate components MonthPicker and YearPicker. It can look like the same as in the datepicker like in the picture below. We can also use these in datepicker itself?

image

This branch is waiting to be deployed

1 waiting deployment
development — 934367de Waiting Nov 30, 2026 by aktasmehmet via Chromatic #572
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants