Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,9 @@ export default class DatePicker extends React.Component {
});

this.props.onChange(changedDate);
this.setOpen(false);
if (this.props.shouldCloseOnSelect) {
this.setOpen(false);
}
this.setState({ inputValue: null });
};

Expand Down
12 changes: 12 additions & 0 deletions test/timepicker_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,18 @@ describe("TimePicker", () => {
expect(getInputString()).to.equal("February 28, 2018 4:43 PM");
});

it("should not close datepicker after time clicked when shouldCloseOnSelect is false", () => {
var datePicker = TestUtils.renderIntoDocument(
<DatePicker shouldCloseOnSelect={false} showTimeSelect />
);
var dateInput = datePicker.input;
TestUtils.Simulate.focus(ReactDOM.findDOMNode(dateInput));
const time = TestUtils.findRenderedComponentWithType(datePicker, Time);
const lis = TestUtils.scryRenderedDOMComponentsWithTag(time, "li");
TestUtils.Simulate.click(lis[0]);
expect(datePicker.state.open).to.be.true;
});

function setManually(string) {
TestUtils.Simulate.focus(datePicker.input);
TestUtils.Simulate.change(datePicker.input, { target: { value: string } });
Expand Down