@@ -111,6 +111,7 @@ export class CalendarBase extends Component<HTMLElement> implements INotifyPrope
111111 protected todayButtonEvent : MouseEvent | KeyboardEvent ;
112112 protected preventChange : boolean = false ;
113113 protected isAngular : boolean = false ;
114+ protected previousDates : boolean = false ;
114115 /**
115116 * Gets or sets the minimum date that can be selected in the Calendar.
116117 *
@@ -966,7 +967,7 @@ export class CalendarBase extends Component<HTMLElement> implements INotifyPrope
966967 const numCells : number = this . weekNumber ? 8 : 7 ;
967968 let tdEles : HTMLElement [ ] ;
968969 if ( this . calendarMode === 'Gregorian' ) {
969- tdEles = this . renderDays ( this . currentDate , value , null , null , isCustomDate ) ;
970+ tdEles = this . renderDays ( this . currentDate , value , null , null , isCustomDate , e ) ;
970971 } else {
971972 tdEles = this . islamicModule . islamicRenderDays ( this . currentDate , value ) ;
972973 }
@@ -977,7 +978,7 @@ export class CalendarBase extends Component<HTMLElement> implements INotifyPrope
977978 this . islamicModule . islamicRenderTemplate ( tdEles , numCells , MONTH , e , value ) ;
978979 }
979980 }
980- protected renderDays ( currentDate : Date , value ?: Date , multiSelection ?: boolean , values ?: Date [ ] , isTodayDate ?: boolean ) : HTMLElement [ ] {
981+ protected renderDays ( currentDate : Date , value ?: Date , multiSelection ?: boolean , values ?: Date [ ] , isTodayDate ?: boolean , e ?: Event ) : HTMLElement [ ] {
981982 const tdEles : HTMLElement [ ] = [ ] ;
982983 const cellsCount : number = 42 ;
983984 const todayDate : Date = isTodayDate ? new Date ( + currentDate ) : this . getDate ( new Date ( ) , this . timezone ) ;
@@ -1068,6 +1069,9 @@ export class CalendarBase extends Component<HTMLElement> implements INotifyPrope
10681069 // if (args.isDisabled && +this.value === +args.date) {
10691070 // this.setProperties({ value: null }, true);
10701071 // }
1072+ let currentTarget : any ;
1073+ if ( ! isNullOrUndefined ( e ) && e . type == 'click' ) {
1074+ currentTarget = e . currentTarget ; }
10711075 if ( multiSelection && ! isNullOrUndefined ( values ) && ! disabledCls ) {
10721076 for ( let tempValue : number = 0 ; tempValue < values . length ; tempValue ++ ) {
10731077 const type : string = ( this . calendarMode === 'Gregorian' ) ? 'gregorian' : 'islamic' ;
@@ -1077,7 +1081,23 @@ export class CalendarBase extends Component<HTMLElement> implements INotifyPrope
10771081 if ( ( localDateString === tempDateString && this . getDateVal ( localDate , values [ tempValue ] ) )
10781082 || ( this . getDateVal ( localDate , value ) ) ) {
10791083 addClass ( [ tdEle ] , SELECTED ) ;
1080- } else {
1084+ } if ( ! isNullOrUndefined ( currentTarget ) && currentTarget . innerText === tdEle . innerText && this . previousDates && currentTarget . classList . contains ( SELECTED ) ) {
1085+ removeClass ( [ tdEle ] , SELECTED ) ;
1086+ this . previousDates = false ;
1087+ const copyValues : Date [ ] = this . copyValues ( values ) ;
1088+ for ( let i : number = 0 ; i < copyValues . length ; i ++ ) {
1089+ const type : string = ( this . calendarMode === 'Gregorian' ) ? 'gregorian' : 'islamic' ;
1090+ const formatOptions : object = { format : null , type : 'date' , skeleton : 'short' , calendar : type } ;
1091+ const localDateString : string = this . globalize . formatDate ( date , formatOptions ) ;
1092+ const tempDateString : string = this . globalize . formatDate ( copyValues [ i ] , formatOptions ) ;
1093+ if ( localDateString === tempDateString ) {
1094+ const index : number = copyValues . indexOf ( copyValues [ i ] ) ;
1095+ copyValues . splice ( index , 1 ) ;
1096+ }
1097+ }
1098+ this . setProperties ( { values : copyValues } , true ) ;
1099+ }
1100+ else {
10811101 this . updateFocus ( otherMnthBool , disabledCls , localDate , tdEle , currentDate ) ;
10821102 }
10831103 }
@@ -2451,8 +2471,8 @@ export class Calendar extends CalendarBase {
24512471 protected renderMonths ( e ?: Event , value ?: Date , isCustomDate ?: boolean ) : void {
24522472 super . renderMonths ( e , this . value , isCustomDate ) ;
24532473 }
2454- protected renderDays ( currentDate : Date , value ?: Date , isMultiSelect ?: boolean , values ?: Date [ ] , isCustomDate ?: boolean ) : HTMLElement [ ] {
2455- const tempDays : HTMLElement [ ] = super . renderDays ( currentDate , this . value , this . isMultiSelection , this . values , isCustomDate ) ;
2474+ protected renderDays ( currentDate : Date , value ?: Date , isMultiSelect ?: boolean , values ?: Date [ ] , isCustomDate ?: boolean , e ?: Event ) : HTMLElement [ ] {
2475+ const tempDays : HTMLElement [ ] = super . renderDays ( currentDate , this . value , this . isMultiSelection , this . values , isCustomDate , e ) ;
24562476 if ( this . isMultiSelection ) {
24572477 super . validateValues ( this . isMultiSelection , this . values ) ;
24582478 }
@@ -2488,9 +2508,14 @@ export class Calendar extends CalendarBase {
24882508 if ( eve . classList . contains ( OTHERMONTH ) ) {
24892509 if ( this . isMultiSelection ) {
24902510 const copyValues : Date [ ] = this . copyValues ( this . values ) ;
2511+ if ( copyValues . toString ( ) . indexOf ( this . getIdValue ( e , null ) . toString ( ) ) === - 1 ) {
24912512 copyValues . push ( this . getIdValue ( e , null ) ) ;
24922513 this . setProperties ( { values : copyValues } , true ) ;
24932514 this . setProperties ( { value : this . values [ this . values . length - 1 ] } , true ) ;
2515+ }
2516+ else {
2517+ this . previousDates = true ;
2518+ }
24942519 } else {
24952520 this . setProperties ( { value : this . getIdValue ( e , null ) } , true ) ;
24962521 }
0 commit comments