Adds the closeOnTab prop.
| | |
| | | propTypes: { |
| | | // value: TYPES.object | TYPES.string, |
| | | // defaultValue: TYPES.object | TYPES.string, |
| | | closeOnSelect: TYPES.bool, |
| | | onFocus: TYPES.func, |
| | | onBlur: TYPES.func, |
| | | onChange: TYPES.func, |
| | |
| | | viewMode: TYPES.oneOf(['years', 'months', 'days', 'time']), |
| | | isValidDate: TYPES.func, |
| | | open: TYPES.bool, |
| | | strictParsing: TYPES.bool |
| | | strictParsing: TYPES.bool, |
| | | closeOnSelect: TYPES.bool, |
| | | closeOnTab: TYPES.bool |
| | | }, |
| | | |
| | | getDefaultProps: function() { |
| | |
| | | onChange: nof, |
| | | timeFormat: true, |
| | | dateFormat: true, |
| | | strictParsing: true |
| | | strictParsing: true, |
| | | closeOnSelect: false, |
| | | closeOnTab: true |
| | | }; |
| | | }, |
| | | |
| | |
| | | return this.setState( update, function() { |
| | | return this.props.onChange( localMoment.isValid() ? localMoment : this.state.inputValue ); |
| | | }); |
| | | }, |
| | | |
| | | onInputKey: function( e ){ |
| | | if( e.which === 9 && this.props.closeOnTab ){ |
| | | this.closeCalendar(); |
| | | } |
| | | }, |
| | | |
| | | showView: function( view ){ |
| | |
| | | className: 'form-control', |
| | | onFocus: this.openCalendar, |
| | | onChange: this.onInputChange, |
| | | onKeyDown: this.onInputKey, |
| | | value: this.state.inputValue |
| | | }, this.props.inputProps ))]; |
| | | } else { |
| | |
| | | trigger( 'click', document.body ); |
| | | }); |
| | | |
| | | it( 'closeOnTab:true', function(){ |
| | | createDatetime({ value: date }); |
| | | |
| | | assert.equal( dt.dt().className.indexOf( 'rdtOpen' ), -1 ); |
| | | ev.focus( dt.input() ); |
| | | assert.notEqual( dt.dt().className.indexOf( 'rdtOpen' ), -1 ); |
| | | TestUtils.Simulate.keyDown(dt.input(), {key: "Tab", keyCode: 9, which: 9}); |
| | | assert.equal( dt.dt().className.indexOf( 'rdtOpen' ), -1 ); |
| | | trigger( 'click', document.body ); |
| | | }); |
| | | |
| | | it( 'closeOnTab:false', function(){ |
| | | createDatetime({ value: date, closeOnTab: false }); |
| | | |
| | | assert.equal( dt.dt().className.indexOf( 'rdtOpen' ), -1 ); |
| | | ev.focus( dt.input() ); |
| | | assert.notEqual( dt.dt().className.indexOf( 'rdtOpen' ), -1 ); |
| | | TestUtils.Simulate.keyDown(dt.input(), {key: "Tab", keyCode: 9, which: 9}); |
| | | assert.notEqual( dt.dt().className.indexOf( 'rdtOpen' ), -1 ); |
| | | trigger( 'click', document.body ); |
| | | }); |
| | | |
| | | it( 'increase time', function( done ){ |
| | | var i = 0; |
| | | createDatetime({ timeFormat: "HH:mm:ss:SSS", viewMode: 'time', defaultValue: date, onChange: function( selected ){ |