Skip to content

Commit

Permalink
Merge pull request #1351 from manubo/add-type-to-close-button
Browse files Browse the repository at this point in the history
Set type attribute of the clear button to "button"
  • Loading branch information
rafeememon authored Apr 9, 2018
2 parents 3b1efbe + f86a8e4 commit 83cf74f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -605,6 +605,7 @@ export default class DatePicker extends React.Component {
if (this.props.isClearable && this.props.selected != null) {
return (
<button
type="button"
className="react-datepicker__close-icon"
onClick={this.onClearClick}
title={this.props.clearButtonTitle}
Expand Down
11 changes: 11 additions & 0 deletions test/datepicker_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,17 @@ describe("DatePicker", () => {
);
});

it("should set the type attribute on the clear button to button", () => {
var datePicker = TestUtils.renderIntoDocument(
<DatePicker selected={utils.newDate("2015-12-15")} isClearable />
);
var clearButton = TestUtils.findRenderedDOMComponentWithClass(
datePicker,
"react-datepicker__close-icon"
);
expect(clearButton.type).to.equal("button");
});

it("should allow clearing the date when isClearable is true", () => {
var cleared = false;
function handleChange(d) {
Expand Down

0 comments on commit 83cf74f

Please sign in to comment.