Skip to content

Commit

Permalink
Clear button is not working when date is given as input #962 (#1071)
Browse files Browse the repository at this point in the history
  • Loading branch information
mkovrigovich authored and martijnrusschen committed Oct 16, 2017
1 parent ce0f417 commit e9656c7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/datepicker.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,7 @@ export default class DatePicker extends React.Component {
onClearClick = (event) => {
event.preventDefault()
this.props.onChange(null, event)
this.setState({ inputValue: null })
}

renderCalendar = () => {
Expand Down
11 changes: 11 additions & 0 deletions test/datepicker_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,17 @@ describe('DatePicker', () => {
expect(cleared).to.be.true
})

it('should clear input value in the local state', () => {
var datePicker = TestUtils.renderIntoDocument(
<DatePicker
selected={utils.newDate('2015-12-15')}
isClearable />
)
var clearButton = TestUtils.findRenderedDOMComponentWithClass(datePicker, 'react-datepicker__close-icon')
TestUtils.Simulate.click(clearButton)
expect(datePicker.state.inputValue).to.be.null
})

it('should save time from the selected date', () => {
const selected = utils.newDate('2015-12-20 10:11:12')
let date
Expand Down

0 comments on commit e9656c7

Please sign in to comment.