@@ -2732,7 +2732,7 @@ describe('igxOverlay', () => {
2732
2732
button . dispatchEvent ( new MouseEvent ( 'click' ) ) ;
2733
2733
} ) ) ;
2734
2734
2735
- it ( 'Should closes the component when esc key is pressed.' , fakeAsync ( ( ) => {
2735
+ it ( 'Should close the component when esc key is pressed.' , fakeAsync ( ( ) => {
2736
2736
const fixture = TestBed . createComponent ( EmptyPageComponent ) ;
2737
2737
const overlay = fixture . componentInstance . overlay ;
2738
2738
const overlaySettings : OverlaySettings = {
@@ -2761,6 +2761,35 @@ describe('igxOverlay', () => {
2761
2761
tick ( ) ;
2762
2762
} ) ) ;
2763
2763
2764
+ it ( 'Should not close the component when esc key is pressed and closeOnEsc is false' , fakeAsync ( ( ) => {
2765
+ const fixture = TestBed . createComponent ( EmptyPageComponent ) ;
2766
+ const overlay = fixture . componentInstance . overlay ;
2767
+ const overlaySettings : OverlaySettings = {
2768
+ modal : true ,
2769
+ closeOnEsc : false ,
2770
+ positionStrategy : new GlobalPositionStrategy ( )
2771
+ } ;
2772
+ const targetButton = 'Escape' ;
2773
+ const escEvent = new KeyboardEvent ( 'keydown' , {
2774
+ key : targetButton
2775
+ } ) ;
2776
+
2777
+ overlay . show ( overlay . attach ( SimpleDynamicComponent ) , overlaySettings ) ;
2778
+ tick ( ) ;
2779
+
2780
+ let overlayWrapper = document . getElementsByClassName ( CLASS_OVERLAY_WRAPPER_MODAL ) [ 0 ] ;
2781
+ overlayWrapper . addEventListener ( 'keydown' , ( event : KeyboardEvent ) => {
2782
+ if ( event . key === targetButton ) {
2783
+ overlayWrapper = document . getElementsByClassName ( CLASS_OVERLAY_WRAPPER_MODAL ) [ 0 ] ;
2784
+ }
2785
+ } ) ;
2786
+ overlayWrapper . dispatchEvent ( escEvent ) ;
2787
+ tick ( ) ;
2788
+ fixture . detectChanges ( ) ;
2789
+
2790
+ expect ( overlayWrapper ) . toBeTruthy ( ) ;
2791
+ } ) ) ;
2792
+
2764
2793
// Test #1883 #1820
2765
2794
it ( 'It should close the component when esc key is pressed and there were other keys pressed prior to esc.' , fakeAsync ( ( ) => {
2766
2795
const fixture = TestBed . createComponent ( EmptyPageComponent ) ;
0 commit comments