Skip to content

Commit b6a976f

Browse files
authored
Merge pull request #7741 from IgniteUI/bpenkov/overlay-close-on-escape
Add closeOnEsc property in overlay settings
2 parents 50f03c8 + 64202bf commit b6a976f

File tree

8 files changed

+103
-19
lines changed

8 files changed

+103
-19
lines changed

CHANGELOG.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,12 @@ All notable changes for each version of this project will be documented in this
77
### General
88
- `igxCombo`
99
- **Behavioral Change** - Change default positioning strategy from `ConnectedPositioningStrategy` to `AutoPositionStrategy`. The [`Auto`](https://www.infragistics.com/products/ignite-ui-angular/angular/components/overlay_position.html#auto) strategy will initially try to show the element like the Connected strategy does. If the element goes out of the viewport Auto will flip the starting point and the direction, i.e. if the direction is 'bottom', it will switch it to 'top' and so on. If after flipping direction the content goes out of the view, auto strategy will revert to initial start point and direction and will push the content into the view. Note after pushing the content it may hide the combo's input.
10+
- `IgxOverlay`
11+
- Added new property - `closeOnEsc` - in `OverlaySettings`. The overlay can now be prevented from closing, on escape keypress, by setting the property to `false`, by default it's `true`.
12+
- `igxDialog`
13+
- Added `closeOnEscapeKey` - with it, the dialog can be allowed or prevented from closing when `Esc` is pressed.
1014
- `IgxNavbar`:
1115
- **Breaking Changes** - The `igx-action-icon` has been renamed to `igx-navbar-action`. It should get renamed in your components via `ng update`;
12-
1316
### New Features
1417
- `IgxGridState` directive
1518
- Added support for expansion states, column selection and row pinning.

projects/igniteui-angular/src/lib/date-picker/date-picker.component.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -783,6 +783,7 @@ export class IgxDatePickerComponent implements IDatePicker, ControlValueAccessor
783783

784784
this._modalOverlaySettings = {
785785
closeOnOutsideClick: true,
786+
closeOnEsc: true,
786787
modal: true,
787788
outlet: this.outlet
788789
};

projects/igniteui-angular/src/lib/dialog/dialog.component.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,15 @@ export class IgxDialogComponent implements IToggleView, OnInit, OnDestroy, After
8383
this._isModal = val;
8484
}
8585

86+
get closeOnEscapeKey() {
87+
return this._closeOnEscapeKey;
88+
}
89+
90+
set closeOnEscapeKey(val: boolean) {
91+
this._overlayDefaultSettings.closeOnEsc = val;
92+
this._closeOnEscapeKey = val;
93+
}
94+
8695
/**
8796
* An @Input property controlling the `title` of the dialog.
8897
* ```html
@@ -301,6 +310,7 @@ export class IgxDialogComponent implements IToggleView, OnInit, OnDestroy, After
301310

302311
private _overlayDefaultSettings: OverlaySettings;
303312
private _closeOnOutsideSelect = false;
313+
private _closeOnEscapeKey = true;
304314
private _isModal = true;
305315
protected destroy$ = new Subject<boolean>();
306316

@@ -404,6 +414,7 @@ export class IgxDialogComponent implements IToggleView, OnInit, OnDestroy, After
404414
positionStrategy: new GlobalPositionStrategy(this._positionSettings),
405415
scrollStrategy: new NoOpScrollStrategy(),
406416
modal: this.isModal,
417+
closeOnEsc: this._closeOnEscapeKey,
407418
closeOnOutsideClick: this.closeOnOutsideSelect
408419
};
409420
}
@@ -503,7 +514,6 @@ export class IgxDialogComponent implements IToggleView, OnInit, OnDestroy, After
503514
}
504515

505516
}
506-
507517
}
508518

509519
export interface IDialogEventArgs extends IBaseEventArgs {

projects/igniteui-angular/src/lib/directives/toggle/toggle.directive.spec.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -475,6 +475,7 @@ describe('IgxToggle', () => {
475475
positionStrategy: jasmine.any(ConnectedPositioningStrategy) as any,
476476
closeOnOutsideClick: true,
477477
modal: false,
478+
closeOnEsc: true,
478479
scrollStrategy: jasmine.any(AbsoluteScrollStrategy) as any,
479480
excludePositionTarget: true
480481
};
@@ -498,6 +499,7 @@ describe('IgxToggle', () => {
498499
positionStrategy: jasmine.any(ConnectedPositioningStrategy) as any,
499500
closeOnOutsideClick: true,
500501
modal: false,
502+
closeOnEsc: true,
501503
scrollStrategy: jasmine.any(AbsoluteScrollStrategy) as any,
502504
excludePositionTarget: true
503505
};
@@ -533,6 +535,7 @@ describe('IgxToggle', () => {
533535
positionStrategy: jasmine.any(ConnectedPositioningStrategy) as any,
534536
closeOnOutsideClick: true,
535537
modal: false,
538+
closeOnEsc: true,
536539
scrollStrategy: jasmine.any(AbsoluteScrollStrategy) as any,
537540
excludePositionTarget: true
538541
};
@@ -591,6 +594,7 @@ describe('IgxToggle', () => {
591594
positionStrategy: jasmine.any(ConnectedPositioningStrategy) as any,
592595
closeOnOutsideClick: true,
593596
modal: false,
597+
closeOnEsc: true,
594598
scrollStrategy: jasmine.any(AbsoluteScrollStrategy) as any,
595599
outlet: jasmine.any(IgxOverlayOutletDirective) as any,
596600
excludePositionTarget: true

projects/igniteui-angular/src/lib/directives/toggle/toggle.directive.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,7 @@ export class IgxToggleActionDirective implements OnInit {
429429
scrollStrategy: new AbsoluteScrollStrategy(),
430430
closeOnOutsideClick: true,
431431
modal: false,
432+
closeOnEsc: true,
432433
excludePositionTarget: true
433434
};
434435
}

0 commit comments

Comments
 (0)