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 @@ -973,6 +973,35 @@ describe('igxOverlay', () => {
973973 expect ( element . style . width ) . toBe ( '200px' ) ;
974974 expect ( element . style . height ) . toBe ( '100px' ) ;
975975 } ) ;
976+
977+ it ( 'should close overlay on outside click when target is point, #8297' , fakeAsync ( ( ) => {
978+ const fix = TestBed . createComponent ( EmptyPageComponent ) ;
979+ const button = fix . componentInstance . buttonElement ;
980+ const overlay = fix . componentInstance . overlay ;
981+ fix . detectChanges ( ) ;
982+
983+ const overlaySettings : OverlaySettings = {
984+ modal : false ,
985+ closeOnOutsideClick : true ,
986+ positionStrategy : new ConnectedPositioningStrategy ( )
987+ } ;
988+
989+ overlaySettings . positionStrategy . settings . target = new Point ( 10 , 10 ) ;
990+
991+ overlay . show ( overlay . attach ( SimpleDynamicComponent ) , overlaySettings ) ;
992+ tick ( ) ;
993+ fix . detectChanges ( ) ;
994+
995+ let overlayDiv : Element = document . getElementsByClassName ( CLASS_OVERLAY_MAIN ) [ 0 ] ;
996+ expect ( overlayDiv ) . toBeDefined ( ) ;
997+
998+ document . body . click ( ) ;
999+ tick ( ) ;
1000+ fix . detectChanges ( ) ;
1001+
1002+ overlayDiv = document . getElementsByClassName ( CLASS_OVERLAY_MAIN ) [ 0 ] ;
1003+ expect ( overlayDiv ) . toBeUndefined ( ) ;
1004+ } ) ) ;
9761005 } ) ;
9771006
9781007 describe ( 'Unit Tests - Scroll Strategies: ' , ( ) => {
Original file line number Diff line number Diff line change @@ -657,7 +657,7 @@ export class IgxOverlayService implements OnDestroy {
657657 // if we should exclude position target check if the click is over it. If so do not close overlay
658658 const positionTarget = info . settings . positionStrategy . settings . target as HTMLElement ;
659659 let clickOnPositionTarget = false ;
660- if ( positionTarget ) {
660+ if ( positionTarget && positionTarget . contains ) {
661661 clickOnPositionTarget = positionTarget . contains ( target ) ;
662662 }
663663
You can’t perform that action at this time.
0 commit comments