@@ -62,36 +62,25 @@ export class Daterangepicker implements OnInit, DoCheck, OnChanges {
6262 @HostListener ( 'document:mouseup' , [ '$event' ] )
6363 @HostListener ( 'document:keyup' , [ '$event' ] )
6464 handleOutsideClick ( event ) {
65+ console . log ( event ) ;
6566 if ( ! this . derivedOptions . disabled ) {
66- let current : any = event . target ;
67+ const current : any = event . target ;
6768 const host : any = this . elem . nativeElement ;
68- if ( host . compareDocumentPosition ) {
69- if (
70- host . compareDocumentPosition ( current ) &
71- window . Node . DOCUMENT_POSITION_CONTAINED_BY
72- ) {
73- this . storeOldDates ( ) ;
74- return this . toggleCalendars ( true ) ;
75- }
76- } else if ( host . contains ) {
77- if ( host . contains ( current ) ) {
78- this . storeOldDates ( ) ;
79- return this . toggleCalendars ( true ) ;
69+ if (
70+ host . compareDocumentPosition ( current ) &
71+ window . Node . DOCUMENT_POSITION_CONTAINED_BY
72+ ) {
73+ if ( event . key === 'Escape' ) {
74+ return this . toggleCalendars ( false ) ;
8075 }
81- } else {
82- do {
83- if ( current === host ) {
84- this . storeOldDates ( ) ;
85- return this . toggleCalendars ( true ) ;
86- }
87- current = current . parentNode ;
88- } while ( current ) ;
76+ this . storeOldDates ( ) ;
77+ return this . toggleCalendars ( true ) ;
8978 }
9079 if ( this . showCalendars ) {
9180 if ( ! this . derivedOptions . autoApply ) {
9281 this . restoreOldDates ( ) ;
9382 }
94- this . toggleCalendars ( false ) ;
83+ return this . toggleCalendars ( false ) ;
9584 }
9685 }
9786 }
0 commit comments