Dennis Alves
2017-08-22 704c18fe9302dda68dfb8f18d85baea3739a2147
Added support for "disableOnClickOutside" property.
2 files modified
24 ■■■■■ changed files
DateTime.js 2 ●●● patch | view | raw | blame | history
test/tests.spec.js 22 ●●●●● patch | view | raw | blame | history
DateTime.js
@@ -347,7 +347,7 @@
    },
    handleClickOutside: function() {
        if ( this.props.input && this.state.open && !this.props.open ) {
        if ( this.props.input && this.state.open && !this.props.open && !this.props.disableOnClickOutside ) {
            this.setState({ open: false }, function() {
                this.props.onBlur( this.state.selectedDate || this.state.inputValue );
            });
test/tests.spec.js
@@ -522,6 +522,28 @@
            expect(utils.isOpen(component)).toBeTruthy();
        });
        it('disableOnClickOutside=true', () => {
            const date = new Date(2000, 0, 15, 2, 2, 2, 2),
                component = utils.createDatetime({ value: date, disableOnClickOutside: true });
            expect(utils.isOpen(component)).toBeFalsy();
            utils.openDatepicker(component);
            expect(utils.isOpen(component)).toBeTruthy();
            document.dispatchEvent(new Event('mousedown'));
            expect(utils.isOpen(component)).toBeTruthy();
        });
    it('disableOnClickOutside=false', () => {
            const date = new Date(2000, 0, 15, 2, 2, 2, 2),
                component = utils.createDatetime({ value: date, disableOnClickOutside: false });
            expect(utils.isOpen(component)).toBeFalsy();
            utils.openDatepicker(component);
            expect(utils.isOpen(component)).toBeTruthy();
            document.dispatchEvent(new Event('mousedown'));
            expect(utils.isOpen(component)).toBeFalsy();
        });
        it('increase time', () => {
            let i = 0;
            const date = new Date(2000, 0, 15, 2, 2, 2, 2),