From f7bfec04ecae02e39aa0cfac82f48b03ce6943dc Mon Sep 17 00:00:00 2001 From: Giampaolo Bellavite Date: Sat, 7 Jul 2018 11:57:51 +0200 Subject: [PATCH] Do not call `focus` if `input` is not defined See https://github.com/gpbl/react-day-picker/issues/746#issuecomment-403203664 --- src/DayPickerInput.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/DayPickerInput.js b/src/DayPickerInput.js index ae3288eedc..7deb0e8d2b 100644 --- a/src/DayPickerInput.js +++ b/src/DayPickerInput.js @@ -365,7 +365,11 @@ export default class DayPickerInput extends React.Component { handleOverlayFocus(e) { e.preventDefault(); this.overlayHasFocus = true; - if (!this.props.keepFocus || typeof this.input.focus !== 'function') { + if ( + !this.props.keepFocus || + !this.input || + typeof this.input.focus !== 'function' + ) { return; } this.input.focus();