@@ -80,6 +80,8 @@ const defaultProps = {
80
80
phrases : {
81
81
closeDatePicker : 'Close' ,
82
82
clearDates : 'Clear Dates' ,
83
+ jumpToPrevMonth : 'Jump to previous month' ,
84
+ jumpToNextMonth : 'Jump to next month' ,
83
85
} ,
84
86
} ;
85
87
@@ -88,12 +90,14 @@ export default class DateRangePicker extends React.Component {
88
90
super ( props ) ;
89
91
this . state = {
90
92
dayPickerContainerStyles : { } ,
93
+ isDateRangePickerInputFocused : false ,
91
94
isDayPickerFocused : false ,
92
95
} ;
93
96
94
97
this . onOutsideClick = this . onOutsideClick . bind ( this ) ;
95
- this . onFocusDayPicker = this . onFocusDayPicker . bind ( this ) ;
96
- this . onBlurDayPicker = this . onBlurDayPicker . bind ( this ) ;
98
+ this . onDateRangePickerInputFocus = this . onDateRangePickerInputFocus . bind ( this ) ;
99
+ this . onDayPickerFocus = this . onDayPickerFocus . bind ( this ) ;
100
+ this . onDayPickerBlur = this . onDayPickerBlur . bind ( this ) ;
97
101
98
102
this . responsivizePickerPosition = this . responsivizePickerPosition . bind ( this ) ;
99
103
}
@@ -108,6 +112,10 @@ export default class DateRangePicker extends React.Component {
108
112
this . responsivizePickerPosition ( ) ;
109
113
}
110
114
115
+ componentWillReceiveProps ( nextProps ) {
116
+ // set daterangepickinputfocused to true if focusedinput went from nothing to something
117
+ }
118
+
111
119
shouldComponentUpdate ( nextProps , nextState ) {
112
120
return shallowCompare ( this , nextProps , nextState ) ;
113
121
}
@@ -127,17 +135,37 @@ export default class DateRangePicker extends React.Component {
127
135
const { onFocusChange } = this . props ;
128
136
if ( ! this . isOpened ( ) ) return ;
129
137
138
+ this . setState ( {
139
+ isDateRangePickerInputFocused : false ,
140
+ isDayPickerFocused : false ,
141
+ } ) ;
142
+
130
143
onFocusChange ( null ) ;
131
144
}
132
145
133
- onFocusDayPicker ( ) {
146
+ onDateRangePickerInputFocus ( focusedInput ) {
147
+ const { onFocusChange } = this . props ;
148
+
149
+ if ( focusedInput ) {
150
+ this . setState ( {
151
+ isDateRangePickerInputFocused : true ,
152
+ isDayPickerFocused : false ,
153
+ } ) ;
154
+ }
155
+
156
+ onFocusChange ( focusedInput ) ;
157
+ }
158
+
159
+ onDayPickerFocus ( ) {
134
160
this . setState ( {
161
+ isDateRangePickerInputFocused : false ,
135
162
isDayPickerFocused : true ,
136
163
} ) ;
137
164
}
138
165
139
- onBlurDayPicker ( ) {
166
+ onDayPickerBlur ( ) {
140
167
this . setState ( {
168
+ isDateRangePickerInputFocused : true ,
141
169
isDayPickerFocused : false ,
142
170
} ) ;
143
171
}
@@ -238,6 +266,7 @@ export default class DateRangePicker extends React.Component {
238
266
keepOpenOnDateSelect,
239
267
renderDay,
240
268
initialVisibleMonth,
269
+ phrases : { jumpToPrevMonth, jumpToNextMonth } ,
241
270
} = this . props ;
242
271
const { dayPickerContainerStyles, isDayPickerFocused } = this . state ;
243
272
@@ -278,7 +307,11 @@ export default class DateRangePicker extends React.Component {
278
307
keepOpenOnDateSelect = { keepOpenOnDateSelect }
279
308
renderDay = { renderDay }
280
309
isFocused = { isDayPickerFocused }
281
- onBlur = { this . onBlurDayPicker }
310
+ onBlur = { this . onDayPickerBlur }
311
+ phrases = { {
312
+ jumpToPrevMonth,
313
+ jumpToNextMonth,
314
+ } }
282
315
/>
283
316
284
317
{ withFullScreenPortal &&
@@ -321,10 +354,10 @@ export default class DateRangePicker extends React.Component {
321
354
reopenPickerOnClearDates,
322
355
keepOpenOnDateSelect,
323
356
onDatesChange,
324
- onFocusChange,
325
- renderDay,
326
357
} = this . props ;
327
358
359
+ const { isDateRangePickerInputFocused } = this . state ;
360
+
328
361
const onOutsideClick = ( ! withPortal && ! withFullScreenPortal ) ? this . onOutsideClick : undefined ;
329
362
330
363
return (
@@ -352,11 +385,11 @@ export default class DateRangePicker extends React.Component {
352
385
isOutsideRange = { isOutsideRange }
353
386
withFullScreenPortal = { withFullScreenPortal }
354
387
onDatesChange = { onDatesChange }
355
- onFocusChange = { onFocusChange }
356
- renderDay = { renderDay }
357
- onArrowDown = { this . onFocusDayPicker }
388
+ onFocusChange = { this . onDateRangePickerInputFocus }
389
+ onArrowDown = { this . onDayPickerFocus }
358
390
phrases = { phrases }
359
391
screenReaderMessage = { screenReaderInputMessage }
392
+ isFocused = { isDateRangePickerInputFocused }
360
393
/>
361
394
362
395
{ this . maybeRenderDayPickerWithPortal ( ) }
0 commit comments