Skip to content

Commit 4a91ae6

Browse files
ArthurBritomartijnrusschen
authored andcommitted
Add verification to time picker when shouldCloseOnSelect is false (Hacker0x01#1394) (Hacker0x01#1529)
1 parent 6fd129a commit 4a91ae6

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

src/index.jsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,9 @@ export default class DatePicker extends React.Component {
449449
});
450450

451451
this.props.onChange(changedDate);
452-
this.setOpen(false);
452+
if (this.props.shouldCloseOnSelect) {
453+
this.setOpen(false);
454+
}
453455
this.setState({ inputValue: null });
454456
};
455457

test/timepicker_test.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,18 @@ describe("TimePicker", () => {
3939
expect(getInputString()).to.equal("February 28, 2018 4:43 PM");
4040
});
4141

42+
it("should not close datepicker after time clicked when shouldCloseOnSelect is false", () => {
43+
var datePicker = TestUtils.renderIntoDocument(
44+
<DatePicker shouldCloseOnSelect={false} showTimeSelect />
45+
);
46+
var dateInput = datePicker.input;
47+
TestUtils.Simulate.focus(ReactDOM.findDOMNode(dateInput));
48+
const time = TestUtils.findRenderedComponentWithType(datePicker, Time);
49+
const lis = TestUtils.scryRenderedDOMComponentsWithTag(time, "li");
50+
TestUtils.Simulate.click(lis[0]);
51+
expect(datePicker.state.open).to.be.true;
52+
});
53+
4254
function setManually(string) {
4355
TestUtils.Simulate.focus(datePicker.input);
4456
TestUtils.Simulate.change(datePicker.input, { target: { value: string } });

0 commit comments

Comments
 (0)