File tree Expand file tree Collapse file tree 3 files changed +8
-18
lines changed Expand file tree Collapse file tree 3 files changed +8
-18
lines changed Original file line number Diff line number Diff line change @@ -296,26 +296,11 @@ class SemanticDatepicker extends React.Component<
296
296
format,
297
297
keepOpenOnSelect,
298
298
onChange,
299
- clearOnSameDateClick,
300
299
formatOptions,
301
300
} = this . props ;
302
301
303
302
if ( ! newDate ) {
304
- // if clearOnSameDateClick is true (this is the default case)
305
- // then reset the state. This is what was previously the default
306
- // behavior, without a specific prop.
307
- if ( clearOnSameDateClick ) {
308
- this . resetState ( event ) ;
309
- } else {
310
- // Don't reset the state. Instead, close or keep open the
311
- // datepicker according to the value of keepOpenOnSelect.
312
- // Essentially, follow the default behavior of clicking a date
313
- // but without changing the value in state.
314
- this . setState ( {
315
- isVisible : keepOpenOnSelect ,
316
- } ) ;
317
- }
318
-
303
+ this . resetState ( event ) ;
319
304
return ;
320
305
}
321
306
Original file line number Diff line number Diff line change @@ -7,14 +7,18 @@ class DatePicker extends React.Component<BasicDatePickerProps> {
7
7
{ selectable, date } ,
8
8
event : React . SyntheticEvent
9
9
) => {
10
- const { selected : selectedDate , onChange } = this . props ;
10
+ const { clearOnSameDateClick , selected : selectedDate , onChange } = this . props ;
11
11
12
12
if ( ! selectable ) {
13
13
return ;
14
14
}
15
15
16
16
let newDate = date ;
17
- if ( selectedDate && selectedDate . getTime ( ) === date . getTime ( ) ) {
17
+ if (
18
+ selectedDate &&
19
+ selectedDate . getTime ( ) === date . getTime ( ) &&
20
+ clearOnSameDateClick
21
+ ) {
18
22
newDate = null ;
19
23
}
20
24
Original file line number Diff line number Diff line change @@ -99,6 +99,7 @@ export type BaseDatePickerProps = DayzedProps & {
99
99
} ;
100
100
101
101
export interface BasicDatePickerProps extends BaseDatePickerProps {
102
+ clearOnSameDateClick ?: boolean
102
103
onChange : ( event : React . SyntheticEvent , date : Date | null ) => void ;
103
104
selected : Date ;
104
105
}
You can’t perform that action at this time.
0 commit comments