File tree Expand file tree Collapse file tree 2 files changed +30
-1
lines changed
projects/igniteui-angular/src/lib/services/overlay Expand file tree Collapse file tree 2 files changed +30
-1
lines changed Original file line number Diff line number Diff line change @@ -967,6 +967,35 @@ describe('igxOverlay', () => {
967967 expect ( element . style . width ) . toBe ( '200px' ) ;
968968 expect ( element . style . height ) . toBe ( '100px' ) ;
969969 } ) ;
970+
971+ it ( 'should close overlay on outside click when target is point, #8297' , fakeAsync ( ( ) => {
972+ const fix = TestBed . createComponent ( EmptyPageComponent ) ;
973+ const button = fix . componentInstance . buttonElement ;
974+ const overlay = fix . componentInstance . overlay ;
975+ fix . detectChanges ( ) ;
976+
977+ const overlaySettings : OverlaySettings = {
978+ modal : false ,
979+ closeOnOutsideClick : true ,
980+ positionStrategy : new ConnectedPositioningStrategy ( )
981+ } ;
982+
983+ overlaySettings . positionStrategy . settings . target = new Point ( 10 , 10 ) ;
984+
985+ overlay . show ( overlay . attach ( SimpleDynamicComponent ) , overlaySettings ) ;
986+ tick ( ) ;
987+ fix . detectChanges ( ) ;
988+
989+ let overlayDiv : Element = document . getElementsByClassName ( CLASS_OVERLAY_MAIN ) [ 0 ] ;
990+ expect ( overlayDiv ) . toBeDefined ( ) ;
991+
992+ document . body . click ( ) ;
993+ tick ( ) ;
994+ fix . detectChanges ( ) ;
995+
996+ overlayDiv = document . getElementsByClassName ( CLASS_OVERLAY_MAIN ) [ 0 ] ;
997+ expect ( overlayDiv ) . toBeUndefined ( ) ;
998+ } ) ) ;
970999 } ) ;
9711000
9721001 describe ( 'Unit Tests - Scroll Strategies: ' , ( ) => {
Original file line number Diff line number Diff line change @@ -664,7 +664,7 @@ export class IgxOverlayService implements OnDestroy {
664664 // if we should exclude position target check if the click is over it. If so do not close overlay
665665 const positionTarget = info . settings . positionStrategy . settings . target as HTMLElement ;
666666 let clickOnPositionTarget = false ;
667- if ( positionTarget ) {
667+ if ( positionTarget && positionTarget . contains ) {
668668 clickOnPositionTarget = positionTarget . contains ( target ) ;
669669 }
670670
You can’t perform that action at this time.
0 commit comments