File tree Expand file tree Collapse file tree 2 files changed +30
-1
lines changed Expand file tree Collapse file tree 2 files changed +30
-1
lines changed Original file line number Diff line number Diff line change @@ -118,6 +118,7 @@ function InnerPicker<DateType>(props: PickerProps<DateType>) {
118118 suffixIcon,
119119 clearIcon,
120120 disabled,
121+ disabledDate,
121122 placeholder,
122123 getPopupContainer,
123124 inputRef,
@@ -241,7 +242,7 @@ function InnerPicker<DateType>(props: PickerProps<DateType>) {
241242 text ,
242243 formatList ,
243244 ) ;
244- if ( inputDate ) {
245+ if ( inputDate && ( ! disabledDate || ! disabledDate ( inputDate ) ) ) {
245246 setSelectedValue ( inputDate ) ;
246247 }
247248 } ;
Original file line number Diff line number Diff line change 11import React from 'react' ;
22import MockDate from 'mockdate' ;
3+ import KeyCode from 'rc-util/lib/KeyCode' ;
34import { spyElementPrototypes } from 'rc-util/lib/test/domHook' ;
45import { Moment } from 'moment' ;
56import {
@@ -506,4 +507,31 @@ describe('Range', () => {
506507 expect ( onPanelChange . mock . calls [ 0 ] [ 1 ] ) . toEqual ( [ 'month' , 'month' ] ) ;
507508 } ) ;
508509 } ) ;
510+
511+ it ( 'type can not change before start time' , ( ) => {
512+ const onChange = jest . fn ( ) ;
513+ const wrapper = mount (
514+ < MomentRangePicker
515+ defaultValue = { [ getMoment ( '2000-01-15' ) , getMoment ( '2000-01-16' ) ] }
516+ onChange = { onChange }
517+ /> ,
518+ ) ;
519+
520+ wrapper
521+ . find ( 'input' )
522+ . last ( )
523+ . simulate ( 'change' , {
524+ target : {
525+ value : '2000-01-11' ,
526+ } ,
527+ } ) ;
528+ wrapper
529+ . find ( 'input' )
530+ . last ( )
531+ . simulate ( 'keyDown' , {
532+ which : KeyCode . ENTER ,
533+ } ) ;
534+
535+ expect ( onChange ) . not . toHaveBeenCalled ( ) ;
536+ } ) ;
509537} ) ;
You can’t perform that action at this time.
0 commit comments