Skip to content

Commit

Permalink
Time selector close (#1169)
Browse files Browse the repository at this point in the history
* Only focus when input has a focus method

* When time picker is displayed close picker when time is selected

Don't close picker when only date is selected
  • Loading branch information
Will Munn authored and martijnrusschen committed Dec 16, 2017
1 parent 14f886b commit fb787d0
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/index.jsx
Expand Up @@ -197,7 +197,9 @@ export default class DatePicker extends React.Component {
}

setFocus = () => {
this.input.focus()
if (this.input.focus) {
this.input.focus()
}
}

setOpen = (open) => {
Expand Down Expand Up @@ -268,7 +270,7 @@ export default class DatePicker extends React.Component {
}
)
this.setSelected(date, event)
if (!this.props.shouldCloseOnSelect) {
if (!this.props.shouldCloseOnSelect || this.props.showTimeSelect) {
this.setPreSelection(date)
} else if (!this.props.inline) {
this.setOpen(false)
Expand Down Expand Up @@ -327,6 +329,7 @@ export default class DatePicker extends React.Component {
})

this.props.onChange(changedDate)
this.setOpen(false)
}

onInputClick = () => {
Expand Down

0 comments on commit fb787d0

Please sign in to comment.