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 @@ -881,6 +881,35 @@ describe('igxOverlay', () => {
881881 expect ( element . style . width ) . toBe ( '200px' ) ;
882882 expect ( element . style . height ) . toBe ( '100px' ) ;
883883 } ) ;
884+
885+ it ( 'should close overlay on outside click when target is point, #8297' , fakeAsync ( ( ) => {
886+ const fix = TestBed . createComponent ( EmptyPageComponent ) ;
887+ const button = fix . componentInstance . buttonElement ;
888+ const overlay = fix . componentInstance . overlay ;
889+ fix . detectChanges ( ) ;
890+
891+ const overlaySettings : OverlaySettings = {
892+ modal : false ,
893+ closeOnOutsideClick : true ,
894+ positionStrategy : new ConnectedPositioningStrategy ( )
895+ } ;
896+
897+ overlaySettings . positionStrategy . settings . target = new Point ( 10 , 10 ) ;
898+
899+ overlay . show ( overlay . attach ( SimpleDynamicComponent ) , overlaySettings ) ;
900+ tick ( ) ;
901+ fix . detectChanges ( ) ;
902+
903+ let overlayDiv : Element = document . getElementsByClassName ( CLASS_OVERLAY_MAIN ) [ 0 ] ;
904+ expect ( overlayDiv ) . toBeDefined ( ) ;
905+
906+ document . body . click ( ) ;
907+ tick ( ) ;
908+ fix . detectChanges ( ) ;
909+
910+ overlayDiv = document . getElementsByClassName ( CLASS_OVERLAY_MAIN ) [ 0 ] ;
911+ expect ( overlayDiv ) . toBeUndefined ( ) ;
912+ } ) ) ;
884913 } ) ;
885914
886915 describe ( 'Unit Tests - Scroll Strategies: ' , ( ) => {
Original file line number Diff line number Diff line change @@ -660,7 +660,7 @@ export class IgxOverlayService implements OnDestroy {
660660 // if we should exclude position target check if the click is over it. If so do not close overlay
661661 const positionTarget = info . settings . positionStrategy . settings . target as HTMLElement ;
662662 let clickOnPositionTarget = false ;
663- if ( positionTarget ) {
663+ if ( positionTarget && positionTarget . contains ) {
664664 clickOnPositionTarget = positionTarget . contains ( target ) ;
665665 }
666666
You can’t perform that action at this time.
0 commit comments