File tree Expand file tree Collapse file tree 3 files changed +13
-2
lines changed Expand file tree Collapse file tree 3 files changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -41,6 +41,7 @@ General datepicker component.
41
41
| ` onFocus ` | ` func ` | ` function() {} ` ||
42
42
| ` onKeyDown ` | ` func ` | ` function() {} ` ||
43
43
| ` onMonthChange ` | ` func ` | ` function() {} ` ||
44
+ | ` onYearChange ` | ` func ` | ` function() {} ` ||
44
45
| ` onSelect ` | ` func ` | ` function() {} ` ||
45
46
| ` onWeekSelect ` | ` func ` |||
46
47
| ` openToDate ` | ` object ` |||
@@ -67,4 +68,4 @@ General datepicker component.
67
68
| ` value ` | ` string ` |||
68
69
| ` weekLabel ` | ` string ` |||
69
70
| ` withPortal ` | ` bool ` | ` false ` ||
70
- | ` yearDropdownItemNumber ` | ` number ` |||
71
+ | ` yearDropdownItemNumber ` | ` number ` |||
Original file line number Diff line number Diff line change @@ -41,6 +41,7 @@ export default class Calendar extends React.Component {
41
41
monthsShown : PropTypes . number ,
42
42
onClickOutside : PropTypes . func . isRequired ,
43
43
onMonthChange : PropTypes . func ,
44
+ onYearChange : PropTypes . func ,
44
45
forceShowMonthNavigation : PropTypes . bool ,
45
46
onDropdownFocus : PropTypes . func ,
46
47
onSelect : PropTypes . func . isRequired ,
@@ -146,10 +147,16 @@ export default class Calendar extends React.Component {
146
147
}
147
148
}
148
149
150
+ handleYearChange = ( data ) => {
151
+ if ( this . props . onYearChange ) {
152
+ this . props . onYearChange ( date )
153
+ }
154
+ }
155
+
149
156
changeYear = ( year ) => {
150
157
this . setState ( {
151
158
date : this . state . date . clone ( ) . set ( 'year' , year )
152
- } )
159
+ } , ( ) => this . handleYearChange ( this . state . date ) )
153
160
}
154
161
155
162
changeMonth = ( month ) => {
Original file line number Diff line number Diff line change @@ -56,6 +56,7 @@ export default class DatePicker extends React.Component {
56
56
onFocus : PropTypes . func ,
57
57
onKeyDown : PropTypes . func ,
58
58
onMonthChange : PropTypes . func ,
59
+ onYearChange : PropTypes . func ,
59
60
openToDate : PropTypes . object ,
60
61
peekNextMonth : PropTypes . bool ,
61
62
placeholderText : PropTypes . string ,
@@ -99,6 +100,7 @@ export default class DatePicker extends React.Component {
99
100
onSelect ( ) { } ,
100
101
onClickOutside ( ) { } ,
101
102
onMonthChange ( ) { } ,
103
+ onYearChange ( ) { } ,
102
104
utcOffset : moment ( ) . utcOffset ( ) ,
103
105
monthsShown : 1 ,
104
106
withPortal : false
@@ -380,6 +382,7 @@ export default class DatePicker extends React.Component {
380
382
monthsShown = { this . props . monthsShown }
381
383
onDropdownFocus = { this . handleDropdownFocus }
382
384
onMonthChange = { this . props . onMonthChange }
385
+ onYearChange = { this . props . onYearChange }
383
386
dayClassName = { this . props . dayClassName }
384
387
className = { this . props . calendarClassName }
385
388
yearDropdownItemNumber = { this . props . yearDropdownItemNumber } >
You can’t perform that action at this time.
0 commit comments