|
31 | 31 | @mousedown.prevent="handleCalendarMouseDown" |
32 | 32 | > |
33 | 33 | <div class="dropdown__header"> |
34 | | - <span |
35 | | - class="dropdown__month-and-title--no-hover" |
36 | | - @click="toggleYearPickerDisplay" |
37 | | - > |
38 | | - {{ currentYear }} |
39 | | - </span> |
| 34 | + <span |
| 35 | + class="dropdown__month-and-title--no-hover" |
| 36 | + @click="toggleYearPickerDisplay" |
| 37 | + > |
| 38 | + {{ currentYear }} |
| 39 | + </span> |
40 | 40 |
|
41 | 41 | <CdsFlexbox> |
42 | 42 | <CdsIcon |
@@ -254,7 +254,7 @@ watch(datePickerRef, (newValue) => { |
254 | 254 | function handleMonthSelection(selectedMonth) { |
255 | 255 | internalValue.value = internalValue.value ? internalValue.value : DateTime.now().setLocale('pt-BR').toFormat('dd/MM/yyyy'); |
256 | 256 | showMonthPicker.value = !showMonthPicker.value; |
257 | | - let [day, month, year] = internalValue.value.toFormat('dd/MM/yyyy').split('/'); |
| 257 | + let [, month, year] = internalValue.value.toFormat('dd/MM/yyyy').split('/'); |
258 | 258 | month = selectedMonth.index; |
259 | 259 |
|
260 | 260 | internalValue.value = DateTime.fromObject({ year: year, month: month }).setLocale('pt-BR'); |
@@ -287,15 +287,27 @@ function allowNextYearNavigation() { |
287 | 287 | } |
288 | 288 |
|
289 | 289 | function previousYear() { |
290 | | - if (allowPreviousYearNavigation()) { |
291 | | - internalValue.value = internalValue.value.minus({ year: 1 }); |
| 290 | + if (!allowPreviousYearNavigation()) return; |
| 291 | +
|
| 292 | + if (DateTime.min(internalValue.value.minus({ year: 1 }), minDateObj.value) !== minDateObj.value) { |
| 293 | + internalValue.value = minDateObj.value; |
| 294 | + model.value = internalValue.value.toFormat('yyyy-MM'); |
| 295 | + return; |
292 | 296 | } |
| 297 | +
|
| 298 | + internalValue.value = internalValue.value.minus({ year: 1 }); |
293 | 299 | } |
294 | 300 |
|
295 | 301 | function nextYear() { |
296 | | - if (allowNextYearNavigation()) { |
297 | | - internalValue.value = internalValue.value.plus({ year: 1 }); |
| 302 | + if (!allowNextYearNavigation()) return; |
| 303 | +
|
| 304 | + if (DateTime.max(internalValue.value.plus({ year: 1 }), maxDateObj.value) !== maxDateObj.value) { |
| 305 | + internalValue.value = maxDateObj.value; |
| 306 | + model.value = internalValue.value.toFormat('yyyy-MM'); |
| 307 | + return; |
298 | 308 | } |
| 309 | +
|
| 310 | + internalValue.value = internalValue.value.plus({ year: 1 }); |
299 | 311 | } |
300 | 312 |
|
301 | 313 | function toggleDatePicker() { |
|
0 commit comments