Skip to content

Commit

Permalink
Fixes issues where input was being refocused when the window is blurr…
Browse files Browse the repository at this point in the history
…ed and refocused
  • Loading branch information
Maja Wichrowska committed Dec 13, 2016
1 parent 39ac94b commit 9e6e89b
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/components/DateInput.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React, { PropTypes } from 'react';
import ReactDOM from 'react-dom';
import cx from 'classnames';

import isTouchDevice from '../utils/isTouchDevice';
Expand Down Expand Up @@ -56,10 +55,13 @@ export default class DateInput extends React.Component {

componentDidUpdate(prevProps) {
const { focused } = this.props;
if (prevProps.focused !== focused && focused) {
const startDateInput = ReactDOM.findDOMNode(this.inputRef);
startDateInput.focus();
startDateInput.select();
if (prevProps.focused === focused) return;

if (focused) {
this.inputRef.focus();
this.inputRef.select();
} else {
this.inputRef.blur();
}
}

Expand Down

0 comments on commit 9e6e89b

Please sign in to comment.