@@ -108,9 +108,11 @@ export default class DatePicker extends React.Component {
108108 onClickOutside : PropTypes . func ,
109109 onChangeRaw : PropTypes . func ,
110110 onFocus : PropTypes . func ,
111+ onInputClick : PropTypes . func ,
111112 onKeyDown : PropTypes . func ,
112113 onMonthChange : PropTypes . func ,
113114 onYearChange : PropTypes . func ,
115+ open : PropTypes . bool ,
114116 openToDate : PropTypes . object ,
115117 peekNextMonth : PropTypes . bool ,
116118 placeholderText : PropTypes . string ,
@@ -171,6 +173,7 @@ export default class DatePicker extends React.Component {
171173 onFocus ( ) { } ,
172174 onBlur ( ) { } ,
173175 onKeyDown ( ) { } ,
176+ onInputClick ( ) { } ,
174177 onSelect ( ) { } ,
175178 onClickOutside ( ) { } ,
176179 onMonthChange ( ) { } ,
@@ -272,6 +275,11 @@ export default class DatePicker extends React.Component {
272275 } ) ;
273276 } ;
274277
278+ isCalendarOpen = ( ) =>
279+ this . props . open === undefined
280+ ? this . state . open && ! this . props . disabled && ! this . props . readOnly
281+ : this . props . open ;
282+
275283 handleFocus = event => {
276284 if ( ! this . state . preventFocus ) {
277285 this . props . onFocus ( event ) ;
@@ -428,6 +436,8 @@ export default class DatePicker extends React.Component {
428436 if ( ! this . props . disabled && ! this . props . readOnly ) {
429437 this . setOpen ( true ) ;
430438 }
439+
440+ this . props . onInputClick ( ) ;
431441 } ;
432442
433443 onInputKeyDown = event => {
@@ -514,10 +524,7 @@ export default class DatePicker extends React.Component {
514524 } ;
515525
516526 renderCalendar = ( ) => {
517- if (
518- ! this . props . inline &&
519- ( ! this . state . open || this . props . disabled || this . props . readOnly )
520- ) {
527+ if ( ! this . props . inline && ! this . isCalendarOpen ( ) ) {
521528 return null ;
522529 }
523530 return (
@@ -674,9 +681,7 @@ export default class DatePicker extends React.Component {
674681 return (
675682 < PopperComponent
676683 className = { this . props . popperClassName }
677- hidePopper = {
678- ! this . state . open || this . props . disabled || this . props . readOnly
679- }
684+ hidePopper = { ! this . isCalendarOpen ( ) }
680685 popperModifiers = { this . props . popperModifiers }
681686 targetComponent = {
682687 < div className = "react-datepicker__input-container" >
0 commit comments