Skip to content

Commit cd0ec84

Browse files
authored
Merge branch 'master' into mkirova/feat-7795
2 parents 0e5e118 + 7c82a75 commit cd0ec84

20 files changed

+230
-181
lines changed

CHANGELOG.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +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+
- Make `onSearchInput` event cancellable. The event args type has been changed to `IComboSearchInputEventArgs`, which have the following properties: `searchText` - holds the text typed into the search input, `owner` - holds a reference to the combo component and `cancel` - indicates whether the event should be canceled.
1011
- `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+
- Added new property `closeOnEscape` in `OverlaySettings` that controls whether the overlay should close on escape keypress. By default `closeOnEsc` is set to `false`.
13+
- **Behavioral Change** - `modal` overlays shown directly through the Overlay Service no longer close on Escape by default. That behavior can now be specified using the `closeOnEscape` property.
1214
- `igxDialog`
13-
- Added `closeOnEscapeKey` - with it, the dialog can be allowed or prevented from closing when `Esc` is pressed.
15+
- Added `closeOnEscape` - with it, the dialog can be allowed or prevented from closing when `Esc` is pressed.
1416
- `IgxNavbar`:
1517
- **Breaking Changes** - The `igx-action-icon` has been renamed to `igx-navbar-action`. It should get renamed in your components via `ng update`;
1618
- `igxGrid`
@@ -40,8 +42,8 @@ All notable changes for each version of this project will be documented in this
4042
- `IgxNavbar`
4143
- Added new `igx-navbar-title, igxNavbarTitle` directive that can be used to provide custom content for navbar title. It would override the value of `title` input property.
4244
- `IgxCalendar` and `IgxMonthPicker`
43-
- `onViewDateChanged` emitted after the month/year presented in the view is changed after user interaction.
44-
- `onActiveViewChanged` event emitted after the active view (DEFAULT, YEAR, DECADE) is changed after user interaction.
45+
- `viewDateChanged` emitted after the month/year presented in the view is changed after user interaction.
46+
- `activeViewChanged` event emitted after the active view (DEFAULT, YEAR, DECADE) is changed after user interaction.
4547
- `viewDate` day value is always 1.
4648
- `activeView` setter is now available as an input property.
4749

projects/igniteui-angular/src/lib/calendar/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -175,12 +175,12 @@ Controls the visibility of the dates that do not belong to the current month.
175175
Event fired when a value is selected through UI interaction.
176176
Emits the selected value (depending on the type of selection).
177177

178-
- `onViewDateChanged(): IViewDateChangeEventArgs`
178+
- `viewDateChanged(): IViewDateChangeEventArgs`
179179

180-
Event fired after the the month/year presented in the view is changed.
180+
Event fired after the month/year presented in the view is changed.
181181
Emits an object containing the previous and current value of the `viewDate` property.
182182

183-
- `onActiveViewChanged(): CalendarView`
183+
- `activeViewChanged(): CalendarView`
184184

185185
Event fired after the active view is changed.
186186
Emits an CalendarView enum, indicating the `activeView` property value.

projects/igniteui-angular/src/lib/calendar/calendar-base.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -250,21 +250,21 @@ export class IgxCalendarBaseDirective implements ControlValueAccessor {
250250
/**
251251
* Emits an event when the month in view is changed.
252252
* ```html
253-
* <igx-calendar (onViewDateChanged)="viewDateChanged($event)"></igx-calendar>
253+
* <igx-calendar (viewDateChanged)="viewDateChanged($event)"></igx-calendar>
254254
* ```
255255
* ```typescript
256256
* public viewDateChanged(event: IViewDateChangeEventArgs) {
257-
* let newDate = event.newViewDate;
257+
* let viewDate = event.currentValue;
258258
* }
259259
* ```
260260
*/
261261
@Output()
262-
public onViewDateChanged = new EventEmitter<IViewDateChangeEventArgs>();
262+
public viewDateChanged = new EventEmitter<IViewDateChangeEventArgs>();
263263

264264
/**
265265
* Emits an event when the active view is changed.
266266
* ```html
267-
* <igx-calendar (onActiveViewChanged)="activeViewChanged($event)"></igx-calendar>
267+
* <igx-calendar (activeViewChanged)="activeViewChanged($event)"></igx-calendar>
268268
* ```
269269
* ```typescript
270270
* public activeViewChanged(event: CalendarView) {
@@ -273,7 +273,7 @@ export class IgxCalendarBaseDirective implements ControlValueAccessor {
273273
* ```
274274
*/
275275
@Output()
276-
public onActiveViewChanged = new EventEmitter<CalendarView>();
276+
public activeViewChanged = new EventEmitter<CalendarView>();
277277

278278
/**
279279
* @hidden

projects/igniteui-angular/src/lib/calendar/calendar.component.spec.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1588,14 +1588,14 @@ describe('IgxCalendar - ', () => {
15881588

15891589
expect(year.nativeElement).toBe(document.activeElement);
15901590

1591-
spyOn(calendar.onActiveViewChanged, 'emit').and.callThrough();
1591+
spyOn(calendar.activeViewChanged, 'emit').and.callThrough();
15921592

15931593
UIInteractions.triggerKeyDownEvtUponElem('Enter', document.activeElement);
15941594
fixture.detectChanges();
15951595
tick();
15961596

1597-
expect(calendar.onActiveViewChanged.emit).toHaveBeenCalledTimes(1);
1598-
expect(calendar.onActiveViewChanged.emit).toHaveBeenCalledWith(CalendarView.DECADE);
1597+
expect(calendar.activeViewChanged.emit).toHaveBeenCalledTimes(1);
1598+
expect(calendar.activeViewChanged.emit).toHaveBeenCalledWith(CalendarView.DECADE);
15991599

16001600
const years = dom.queryAll(By.css(HelperTestFunctions.YEAR_CSSCLASS));
16011601
let currentYear = dom.query(By.css(HelperTestFunctions.CURRENT_YEAR_CSSCLASS));
@@ -1617,32 +1617,32 @@ describe('IgxCalendar - ', () => {
16171617
expect(currentYear.nativeElement.textContent.trim()).toMatch('2016');
16181618

16191619
const previousValue = fixture.componentInstance.calendar.viewDate;
1620-
spyOn(calendar.onViewDateChanged, 'emit').and.callThrough();
1620+
spyOn(calendar.viewDateChanged, 'emit').and.callThrough();
16211621

16221622
UIInteractions.triggerKeyDownEvtUponElem('Enter', currentYear.nativeElement);
16231623

16241624
fixture.detectChanges();
16251625
tick();
16261626

16271627
const eventArgs: IViewDateChangeEventArgs = { previousValue, currentValue: fixture.componentInstance.calendar.viewDate };
1628-
expect(calendar.onViewDateChanged.emit).toHaveBeenCalledTimes(1);
1629-
expect(calendar.onViewDateChanged.emit).toHaveBeenCalledWith(eventArgs);
1628+
expect(calendar.viewDateChanged.emit).toHaveBeenCalledTimes(1);
1629+
expect(calendar.viewDateChanged.emit).toHaveBeenCalledWith(eventArgs);
16301630
expect(calendar.viewDate.getFullYear()).toEqual(2016);
16311631
}));
16321632

16331633
it('Should open months view, navigate through and select a month via KB.', fakeAsync(() => {
16341634
const month = dom.queryAll(By.css(HelperTestFunctions.CALENDAR_DATE_CSSCLASS))[0];
16351635
month.nativeElement.focus();
1636-
spyOn(calendar.onActiveViewChanged, 'emit').and.callThrough();
1636+
spyOn(calendar.activeViewChanged, 'emit').and.callThrough();
16371637

16381638
expect(month.nativeElement).toBe(document.activeElement);
16391639

16401640
UIInteractions.triggerKeyDownEvtUponElem('Enter', document.activeElement);
16411641
fixture.detectChanges();
16421642
tick();
16431643

1644-
expect(calendar.onActiveViewChanged.emit).toHaveBeenCalledTimes(1);
1645-
expect(calendar.onActiveViewChanged.emit).toHaveBeenCalledWith(CalendarView.YEAR);
1644+
expect(calendar.activeViewChanged.emit).toHaveBeenCalledTimes(1);
1645+
expect(calendar.activeViewChanged.emit).toHaveBeenCalledWith(CalendarView.YEAR);
16461646

16471647
const months = dom.queryAll(By.css(HelperTestFunctions.MONTH_CSSCLASS));
16481648
const currentMonth = dom.query(By.css(HelperTestFunctions.CURRENT_MONTH_CSSCLASS));
@@ -1672,15 +1672,15 @@ describe('IgxCalendar - ', () => {
16721672
expect(document.activeElement.textContent.trim()).toMatch('Sep');
16731673

16741674
const previousValue = fixture.componentInstance.calendar.viewDate;
1675-
spyOn(calendar.onViewDateChanged, 'emit').and.callThrough();
1675+
spyOn(calendar.viewDateChanged, 'emit').and.callThrough();
16761676

16771677
UIInteractions.triggerKeyDownEvtUponElem('Enter', document.activeElement);
16781678
fixture.detectChanges();
16791679
tick();
16801680

16811681
const eventArgs: IViewDateChangeEventArgs = { previousValue, currentValue: fixture.componentInstance.calendar.viewDate };
1682-
expect(calendar.onViewDateChanged.emit).toHaveBeenCalledTimes(1);
1683-
expect(calendar.onViewDateChanged.emit).toHaveBeenCalledWith(eventArgs);
1682+
expect(calendar.viewDateChanged.emit).toHaveBeenCalledTimes(1);
1683+
expect(calendar.viewDateChanged.emit).toHaveBeenCalledWith(eventArgs);
16841684
expect(calendar.viewDate.getMonth()).toEqual(8);
16851685
}));
16861686

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -717,7 +717,7 @@ export class IgxCalendarComponent extends IgxMonthPickerBaseDirective implements
717717
public animationDone(event) {
718718
if ((event.fromState === ScrollMonth.NONE && (event.toState === ScrollMonth.PREV || event.toState === ScrollMonth.NEXT)) ||
719719
(event.fromState === 'void' && event.toState === ScrollMonth.NONE)) {
720-
this.onViewDateChanged.emit({ previousValue: this.previousViewDate, currentValue: this.viewDate });
720+
this.viewDateChanged.emit({ previousValue: this.previousViewDate, currentValue: this.viewDate });
721721
}
722722

723723
if (this.monthScrollDirection !== ScrollMonth.NONE) {
@@ -751,7 +751,7 @@ export class IgxCalendarComponent extends IgxMonthPickerBaseDirective implements
751751
*/
752752
public viewRendered(event) {
753753
if (event.fromState !== 'void') {
754-
this.onActiveViewChanged.emit(this.activeView);
754+
this.activeViewChanged.emit(this.activeView);
755755
}
756756
}
757757

projects/igniteui-angular/src/lib/calendar/month-picker/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,12 +122,12 @@ The default values are listed below.
122122
Event fired when a value is selected through UI interaction.
123123
Returns the selected value (depending on the type of selection).
124124

125-
- `onViewDateChanged(): IViewDateChangeEventArgs`
125+
- `viewDateChanged(): IViewDateChangeEventArgs`
126126

127-
Event fired after the the month/year presented in the view is changed.
127+
Event fired after the month/year presented in the view is changed.
128128
Emits an object containing the previous and current value of the `viewDate` property.
129129

130-
- `onActiveViewChanged(): CalendarView`
130+
- `activeViewChanged(): CalendarView`
131131

132132
Event fired after the active view is changed.
133133
Emits an CalendarView enum, indicating the `activeView` property value.

projects/igniteui-angular/src/lib/calendar/month-picker/month-picker.component.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ export class IgxMonthPickerComponent extends IgxMonthPickerBaseDirective {
103103
public animationDone(event) {
104104
if ((event.fromState === 'void' && event.toState === '') ||
105105
(event.fromState === '' && (event.toState === ScrollMonth.PREV || event.toState === ScrollMonth.NEXT))) {
106-
this.onViewDateChanged.emit({ previousValue: this.previousViewDate, currentValue: this.viewDate });
106+
this.viewDateChanged.emit({ previousValue: this.previousViewDate, currentValue: this.viewDate });
107107
}
108108
this.yearAction = '';
109109
}
@@ -113,7 +113,7 @@ export class IgxMonthPickerComponent extends IgxMonthPickerBaseDirective {
113113
*/
114114
public viewRendered(event) {
115115
if (event.fromState !== 'void') {
116-
this.onActiveViewChanged.emit(this.activeView);
116+
this.activeViewChanged.emit(this.activeView);
117117
}
118118
}
119119

projects/igniteui-angular/src/lib/combo/combo.component.spec.ts

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import { configureTestSuite } from '../test-utils/configure-suite';
1818
import { DisplayDensity } from '../core/density';
1919
import { AbsoluteScrollStrategy, ConnectedPositioningStrategy } from '../services/public_api';
2020
import { IgxSelectionAPIService } from '../core/selection';
21+
import { CancelableEventArgs } from '../core/utils';
2122

2223
const CSS_CLASS_COMBO = 'igx-combo';
2324
const CSS_CLASS_COMBO_DROPDOWN = 'igx-combo__drop-down';
@@ -530,21 +531,42 @@ describe('igxCombo', () => {
530531
expect(matchSpy).toHaveBeenCalledTimes(1);
531532
expect(combo.onSearchInput.emit).toHaveBeenCalledTimes(0);
532533

534+
const args = {
535+
searchText: 'Fake',
536+
owner: combo,
537+
cancel: false
538+
};
533539
combo.handleInputChange('Fake');
534540
expect(matchSpy).toHaveBeenCalledTimes(2);
535541
expect(combo.onSearchInput.emit).toHaveBeenCalledTimes(1);
536-
expect(combo.onSearchInput.emit).toHaveBeenCalledWith('Fake');
542+
expect(combo.onSearchInput.emit).toHaveBeenCalledWith(args);
537543

544+
args.searchText = '';
538545
combo.handleInputChange('');
539546
expect(matchSpy).toHaveBeenCalledTimes(3);
540547
expect(combo.onSearchInput.emit).toHaveBeenCalledTimes(2);
541-
expect(combo.onSearchInput.emit).toHaveBeenCalledWith('');
548+
expect(combo.onSearchInput.emit).toHaveBeenCalledWith(args);
542549

543550
combo.filterable = false;
544551
combo.handleInputChange();
545552
expect(matchSpy).toHaveBeenCalledTimes(4);
546553
expect(combo.onSearchInput.emit).toHaveBeenCalledTimes(2);
547554
});
555+
it('should be able to cancel onSearchInput', () => {
556+
combo = new IgxComboComponent({ nativeElement: null }, mockCdr, mockSelection as any, mockComboService, null, mockInjector);
557+
combo.ngOnInit();
558+
combo.data = data;
559+
combo.filterable = true;
560+
combo.onSearchInput.subscribe((e) => {
561+
e.cancel = true;
562+
});
563+
const matchSpy = spyOn<any>(combo, 'checkMatch').and.callThrough();
564+
spyOn(combo.onSearchInput, 'emit').and.callThrough();
565+
566+
combo.handleInputChange('Item1');
567+
expect(combo.onSearchInput.emit).toHaveBeenCalledTimes(1);
568+
expect(matchSpy).toHaveBeenCalledTimes(0);
569+
});
548570
});
549571
describe('Initialization and rendering tests: ', () => {
550572
configureTestSuite();

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

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,12 @@ export interface IComboSelectionChangeEventArgs extends CancelableEventArgs, IBa
9696
event?: Event;
9797
}
9898

99+
/** Event emitted when the igx-combo's search input changes */
100+
export interface IComboSearchInputEventArgs extends CancelableEventArgs, IBaseEventArgs {
101+
/** The text that has been typed into the search input */
102+
searchText: string;
103+
}
104+
99105
export interface IComboItemAdditionEvent extends IBaseEventArgs {
100106
oldCollection: any[];
101107
addedItem: any;
@@ -483,7 +489,7 @@ export class IgxComboComponent extends DisplayDensityBase implements IgxComboBas
483489
* ```
484490
*/
485491
@Output()
486-
public onSearchInput = new EventEmitter();
492+
public onSearchInput = new EventEmitter<IComboSearchInputEventArgs>();
487493

488494
/**
489495
* Emitted when new chunk of data is loaded from the virtualization
@@ -981,7 +987,16 @@ export class IgxComboComponent extends DisplayDensityBase implements IgxComboBas
981987
*/
982988
public handleInputChange(event?: string) {
983989
if (event !== undefined) {
984-
this.onSearchInput.emit(event);
990+
const args: IComboSearchInputEventArgs = {
991+
searchText: event,
992+
owner: this,
993+
cancel: false
994+
};
995+
this.onSearchInput.emit(args);
996+
if (args.cancel) {
997+
this.searchValue = null;
998+
return;
999+
}
9851000
}
9861001
this.checkMatch();
9871002
}
@@ -1436,8 +1451,8 @@ export class IgxComboComponent extends DisplayDensityBase implements IgxComboBas
14361451
/** Returns a string that should be populated in the combo's text box */
14371452
private concatDisplayText(selection: any[]): string {
14381453
const value = this.displayKey !== null && this.displayKey !== undefined ?
1439-
this.convertKeysToItems(selection).map(entry => entry[this.displayKey]).join(', ') :
1440-
selection.join(', ');
1454+
this.convertKeysToItems(selection).map(entry => entry[this.displayKey]).join(', ') :
1455+
selection.join(', ');
14411456
return value;
14421457
}
14431458

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -792,8 +792,8 @@ export class IgxDatePickerComponent implements IDatePicker, ControlValueAccessor
792792

793793
this._modalOverlaySettings = {
794794
closeOnOutsideClick: true,
795-
closeOnEsc: true,
796795
modal: true,
796+
closeOnEscape: true,
797797
outlet: this.outlet
798798
};
799799

0 commit comments

Comments
 (0)