File tree Expand file tree Collapse file tree 2 files changed +41
-0
lines changed Expand file tree Collapse file tree 2 files changed +41
-0
lines changed Original file line number Diff line number Diff line change @@ -441,6 +441,11 @@ function Picker<DateType extends object = any>(
441
441
const onPanelSelect = ( date : DateType ) => {
442
442
lastOperation ( 'panel' ) ;
443
443
444
+ // Not change values if multiple and current panel is to match with picker
445
+ if ( multiple && internalMode !== picker ) {
446
+ return ;
447
+ }
448
+
444
449
const nextValues = multiple ? toggleDates ( getCalendarValue ( ) , date ) : [ date ] ;
445
450
446
451
// Only trigger calendar event but not update internal `calendarValue` state
Original file line number Diff line number Diff line change @@ -155,4 +155,40 @@ describe('Picker.Multiple', () => {
155
155
) . toBeFalsy ( ) ;
156
156
} ) ;
157
157
} ) ;
158
+
159
+ it ( 'click year panel should not select' , ( ) => {
160
+ const onChange = jest . fn ( ) ;
161
+ const onCalendarChange = jest . fn ( ) ;
162
+ const { container } = render (
163
+ < DayPicker multiple onChange = { onChange } onCalendarChange = { onCalendarChange } needConfirm /> ,
164
+ ) ;
165
+
166
+ expect ( container . querySelector ( '.rc-picker-multiple' ) ) . toBeTruthy ( ) ;
167
+
168
+ openPicker ( container ) ;
169
+
170
+ // Select year
171
+ fireEvent . click ( document . querySelector ( '.rc-picker-year-btn' ) ) ;
172
+ selectCell ( 1998 ) ;
173
+ expect ( onChange ) . not . toHaveBeenCalled ( ) ;
174
+ expect ( onCalendarChange ) . not . toHaveBeenCalled ( ) ;
175
+
176
+ // Select Month
177
+ selectCell ( 'Oct' ) ;
178
+ expect ( onChange ) . not . toHaveBeenCalled ( ) ;
179
+ expect ( onCalendarChange ) . not . toHaveBeenCalled ( ) ;
180
+
181
+ // Select Date
182
+ selectCell ( 23 ) ;
183
+ expect ( onChange ) . not . toHaveBeenCalled ( ) ;
184
+ expect ( onCalendarChange ) . toHaveBeenCalledWith (
185
+ expect . anything ( ) ,
186
+ [ '1998-10-23' ] ,
187
+ expect . anything ( ) ,
188
+ ) ;
189
+
190
+ // Confirm
191
+ fireEvent . click ( document . querySelector ( '.rc-picker-ok button' ) ) ;
192
+ expect ( onChange ) . toHaveBeenCalledWith ( expect . anything ( ) , [ '1998-10-23' ] ) ;
193
+ } ) ;
158
194
} ) ;
You can’t perform that action at this time.
0 commit comments