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> {
45
45
defaultPickerValue ?: DateType ;
46
46
47
47
// Date
48
- showToday ?: boolean ;
49
48
disabledDate ?: ( date : DateType ) => boolean ;
50
49
51
50
// Render
@@ -68,6 +67,7 @@ export interface PickerPanelBaseProps<DateType>
68
67
export interface PickerPanelDateProps < DateType >
69
68
extends PickerPanelSharedProps < DateType > {
70
69
picker ?: 'date' ;
70
+ showToday ?: boolean ;
71
71
72
72
// Time
73
73
showTime ?: boolean | SharedTimeProps < DateType > ;
@@ -106,7 +106,7 @@ function PickerPanel<DateType>(props: PickerPanelProps<DateType>) {
106
106
defaultValue,
107
107
defaultPickerValue,
108
108
mode,
109
- picker,
109
+ picker = 'date' ,
110
110
tabIndex = 0 ,
111
111
showTime,
112
112
showToday,
@@ -356,7 +356,7 @@ function PickerPanel<DateType>(props: PickerPanelProps<DateType>) {
356
356
}
357
357
358
358
let todayNode : React . ReactNode ;
359
- if ( showToday ) {
359
+ if ( showToday && mergedMode === 'date' && picker === 'date' ) {
360
360
todayNode = (
361
361
< a
362
362
className = { `${ prefixCls } -today-btn` }
Original file line number Diff line number Diff line change @@ -424,12 +424,22 @@ describe('Basic', () => {
424
424
matchFooter ( 'year' ) ;
425
425
} ) ;
426
426
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
+ } ) ;
433
443
} ) ;
434
444
435
445
it ( 'icon' , ( ) => {
You can’t perform that action at this time.
0 commit comments