File tree Expand file tree Collapse file tree 2 files changed +19
-9
lines changed Expand file tree Collapse file tree 2 files changed +19
-9
lines changed Original file line number Diff line number Diff line change @@ -45,7 +45,6 @@ export interface PickerPanelSharedProps<DateType> {
4545 defaultPickerValue ?: DateType ;
4646
4747 // Date
48- showToday ?: boolean ;
4948 disabledDate ?: ( date : DateType ) => boolean ;
5049
5150 // Render
@@ -68,6 +67,7 @@ export interface PickerPanelBaseProps<DateType>
6867export interface PickerPanelDateProps < DateType >
6968 extends PickerPanelSharedProps < DateType > {
7069 picker ?: 'date' ;
70+ showToday ?: boolean ;
7171
7272 // Time
7373 showTime ?: boolean | SharedTimeProps < DateType > ;
@@ -106,7 +106,7 @@ function PickerPanel<DateType>(props: PickerPanelProps<DateType>) {
106106 defaultValue,
107107 defaultPickerValue,
108108 mode,
109- picker,
109+ picker = 'date' ,
110110 tabIndex = 0 ,
111111 showTime,
112112 showToday,
@@ -356,7 +356,7 @@ function PickerPanel<DateType>(props: PickerPanelProps<DateType>) {
356356 }
357357
358358 let todayNode : React . ReactNode ;
359- if ( showToday ) {
359+ if ( showToday && mergedMode === 'date' && picker === 'date' ) {
360360 todayNode = (
361361 < a
362362 className = { `${ prefixCls } -today-btn` }
Original file line number Diff line number Diff line change @@ -424,12 +424,22 @@ describe('Basic', () => {
424424 matchFooter ( 'year' ) ;
425425 } ) ;
426426
427- it ( 'showToday' , ( ) => {
428- const onSelect = jest . fn ( ) ;
429- const wrapper = mount ( < MomentPicker onSelect = { onSelect } showToday /> ) ;
430- wrapper . openPicker ( ) ;
431- wrapper . find ( '.rc-picker-today-btn' ) . simulate ( 'click' ) ;
432- expect ( isSame ( onSelect . mock . calls [ 0 ] [ 0 ] , '1990-09-03' ) ) . toBeTruthy ( ) ;
427+ describe ( 'showToday' , ( ) => {
428+ it ( 'only works on date' , ( ) => {
429+ const onSelect = jest . fn ( ) ;
430+ const wrapper = mount ( < MomentPicker onSelect = { onSelect } showToday /> ) ;
431+ wrapper . openPicker ( ) ;
432+ wrapper . find ( '.rc-picker-today-btn' ) . simulate ( 'click' ) ;
433+ expect ( isSame ( onSelect . mock . calls [ 0 ] [ 0 ] , '1990-09-03' ) ) . toBeTruthy ( ) ;
434+ } ) ;
435+
436+ [ 'decade' , 'year' , 'month' , 'week' ] . forEach ( name => {
437+ it ( `not works on ${ name } ` , ( ) => {
438+ const wrapper = mount ( < MomentPicker picker = { name as any } showToday /> ) ;
439+ wrapper . openPicker ( ) ;
440+ expect ( wrapper . find ( '.rc-picker-today-btn' ) . length ) . toBeFalsy ( ) ;
441+ } ) ;
442+ } ) ;
433443 } ) ;
434444
435445 it ( 'icon' , ( ) => {
You can’t perform that action at this time.
0 commit comments