Skip to content

Commit 704c18f

Browse files
dennis90simeg
authored andcommitted
Added support for "disableOnClickOutside" property.
1 parent 44164f0 commit 704c18f

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

DateTime.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ var Datetime = createClass({
347347
},
348348

349349
handleClickOutside: function() {
350-
if ( this.props.input && this.state.open && !this.props.open ) {
350+
if ( this.props.input && this.state.open && !this.props.open && !this.props.disableOnClickOutside ) {
351351
this.setState({ open: false }, function() {
352352
this.props.onBlur( this.state.selectedDate || this.state.inputValue );
353353
});

test/tests.spec.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -522,6 +522,28 @@ describe('Datetime', () => {
522522
expect(utils.isOpen(component)).toBeTruthy();
523523
});
524524

525+
it('disableOnClickOutside=true', () => {
526+
const date = new Date(2000, 0, 15, 2, 2, 2, 2),
527+
component = utils.createDatetime({ value: date, disableOnClickOutside: true });
528+
529+
expect(utils.isOpen(component)).toBeFalsy();
530+
utils.openDatepicker(component);
531+
expect(utils.isOpen(component)).toBeTruthy();
532+
document.dispatchEvent(new Event('mousedown'));
533+
expect(utils.isOpen(component)).toBeTruthy();
534+
});
535+
536+
it('disableOnClickOutside=false', () => {
537+
const date = new Date(2000, 0, 15, 2, 2, 2, 2),
538+
component = utils.createDatetime({ value: date, disableOnClickOutside: false });
539+
540+
expect(utils.isOpen(component)).toBeFalsy();
541+
utils.openDatepicker(component);
542+
expect(utils.isOpen(component)).toBeTruthy();
543+
document.dispatchEvent(new Event('mousedown'));
544+
expect(utils.isOpen(component)).toBeFalsy();
545+
});
546+
525547
it('increase time', () => {
526548
let i = 0;
527549
const date = new Date(2000, 0, 15, 2, 2, 2, 2),

0 commit comments

Comments
 (0)