Skip to content

Commit

Permalink
Calling onYearChange after year change in fullYear mode #277
Browse files Browse the repository at this point in the history
  • Loading branch information
shahabyazdi committed May 18, 2024
1 parent 2e25a62 commit d5afcec
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

- Better type support for TypeScript
- MapDaysProps added to the index.d.ts [#288](https://github.com/shahabyazdi/react-multi-date-picker/issues/288)
- Calling onYearChange after year change in fullYear mode [#277](https://github.com/shahabyazdi/react-multi-date-picker/issues/277)

# 4.5.0

Expand Down
1 change: 1 addition & 0 deletions src/components/calendar/calendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,7 @@ function Calendar(
formatMonth,
formatYear,
headerOrder,
onYearChange,
}}
/>
<div style={{ position: "relative" }}>
Expand Down
4 changes: 4 additions & 0 deletions src/components/header/header.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React, { isValidElement, cloneElement } from "react";
import Arrow from "../arrow/arrow";
import DateObject from "react-date-object";
import { Fragment } from "react";
import { findFocusable } from "../../shared/handleFocus";
import { findCalendar } from "../../shared/findNode";
Expand All @@ -22,6 +23,7 @@ export default function Header({
formatMonth,
formatYear,
headerOrder,
onYearChange,
}) {
let style = {},
{
Expand Down Expand Up @@ -225,6 +227,8 @@ export default function Header({

if (fullYear) {
date.year += value;

onYearChange?.(new DateObject(date));
} else if (!mustShowYearPicker && !onlyYearPicker) {
date.toFirstOfMonth();

Expand Down

0 comments on commit d5afcec

Please sign in to comment.