Repository navigation
fix(DatePicker-InputDate): Month only picker is introduced - #220
atakanbayrak wants to merge 15 commits into
Conversation
|
Claude finished @aktasmehmet's task in 31s —— View job Review of #220:
|
|
Size Change: +1.21 kB (+0.43%) Total Size: 285 kB 📦 View Changed
ℹ️ View Unchanged
|
| }, [pickerDate, setPickerDate]); | ||
|
|
||
| const handleMonthClick = (month: number) => { | ||
| if (isMonthOnly) { |
There was a problem hiding this comment.
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.
| const handleMonthClick = (month: number) => { | ||
| if (isMonthOnly) { | ||
| const date = new Date(pickerDate.getFullYear(), month, 1); | ||
| selectedDate?.getTime() !== date.getTime() && onDateChange?.(date); |
There was a problem hiding this comment.
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
left a comment
There was a problem hiding this comment.
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?
Description
Month only picker is introduced without creating stand alone component.
Type of Change
Screenshots / Preview
Checklist
How to Test
page.tsx