Gabriel Velo
2016-11-16 f729830c5b40ff73d210b770e5efefbe8d0565f2
Fix onFocus() and onBlur() being triggered on inconsistent state

See #162 for a step-by-step explanation to why this change is needed.
1 files modified
15 ■■■■■ changed files
DateTime.js 15 ●●●●● patch | view | raw | blame | history
DateTime.js
@@ -318,20 +318,23 @@
    openCalendar: function() {
        if (!this.state.open) {
            this.props.onFocus();
            this.setState({ open: true });
            this.setState({ open: true }, function() {
                this.props.onFocus();
            });
        }
    },
    closeCalendar: function() {
        this.setState({ open: false });
        this.props.onBlur( this.state.selectedDate || this.state.inputValue );
        this.setState({ open: false }, function () {
            this.props.onBlur( this.state.selectedDate || this.state.inputValue );
        });
    },
    handleClickOutside: function(){
        if ( this.props.input && this.state.open && !this.props.open ){
            this.setState({ open: false });
            this.props.onBlur( this.state.selectedDate || this.state.inputValue );
            this.setState({ open: false }, function() {
                this.props.onBlur( this.state.selectedDate || this.state.inputValue );
            });
        }
    },