Skip to content

Commit bc8e02e

Browse files
committed
Merge branch '10.2.x' of https://github.com/IgniteUI/igniteui-angular into zkolev/code-coverage-gh-actions-102x
2 parents 4c76c5c + c4fbaec commit bc8e02e

File tree

7 files changed

+83
-12
lines changed

7 files changed

+83
-12
lines changed

projects/igniteui-angular/src/lib/data-operations/filtering-condition.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -548,7 +548,7 @@ export class IgxStringFilteringOperand extends IgxFilteringOperand {
548548
* @memberof IgxStringFilteringOperand
549549
*/
550550
public static applyIgnoreCase(a: string, ignoreCase: boolean): string {
551-
a = a || '';
551+
a = a ?? '';
552552
// bulletproof
553553
return ignoreCase ? ('' + a).toLowerCase() : a;
554554
}

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

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import { IgxDateTimeEditorModule, IgxDateTimeEditorDirective } from '../directiv
1717
import { DateRangeType } from '../core/dates';
1818
import { IgxDateRangePickerComponent, IgxDateRangeEndComponent } from './public_api';
1919
import { IgxIconModule } from '../icon/public_api';
20+
import { AutoPositionStrategy } from '../services/public_api';
2021

2122
// The number of milliseconds in one day
2223
const ONE_DAY = 1000 * 60 * 60 * 24;
@@ -30,6 +31,7 @@ const CSS_CLASS_CALENDAR_TOGGLE = '.igx-toggle';
3031
const CSS_CLASS_ICON = 'igx-icon';
3132
const CSS_CLASS_DONE_BUTTON = 'igx-button--flat';
3233
const CSS_CLASS_LABEL = 'igx-input-group__label';
34+
const CSS_CLASS_OVERLAY_CONTENT = 'igx-overlay__content';
3335

3436
describe('IgxDateRangePicker', () => {
3537
describe('Unit tests: ', () => {
@@ -1120,6 +1122,23 @@ describe('IgxDateRangePicker', () => {
11201122
const result = fixture.componentInstance.formatter({ start: startDate, end: endDate });
11211123
expect(singleInputElement.nativeElement.value).toEqual(result);
11221124
});
1125+
1126+
it('should invoke AutoPositionStrategy by default with proper arguments', fakeAsync(() => {
1127+
fixture = TestBed.createComponent(DateRangeDefaultComponent);
1128+
fixture.detectChanges();
1129+
spyOn<any>(AutoPositionStrategy.prototype, 'position');
1130+
1131+
dateRange = fixture.componentInstance.dateRange;
1132+
dateRange.open();
1133+
tick();
1134+
fixture.detectChanges();
1135+
1136+
const overlayContent = document.getElementsByClassName(CSS_CLASS_OVERLAY_CONTENT)[0] as HTMLElement;
1137+
expect(AutoPositionStrategy.prototype.position).toHaveBeenCalledTimes(1);
1138+
expect(AutoPositionStrategy.prototype.position)
1139+
.toHaveBeenCalledWith(overlayContent, jasmine.anything(), document,
1140+
jasmine.anything(), dateRange.element.nativeElement);
1141+
}));
11231142
});
11241143
});
11251144
});
@@ -1136,7 +1155,7 @@ export class DateRangeTestComponent implements OnInit {
11361155
public minValue: Date | String;
11371156
public maxValue: Date | String;
11381157

1139-
@ViewChild(IgxDateRangePickerComponent, { read: IgxDateRangePickerComponent, static: true })
1158+
@ViewChild(IgxDateRangePickerComponent, { static: true })
11401159
public dateRange: IgxDateRangePickerComponent;
11411160

11421161
public ngOnInit(): void {

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -516,8 +516,8 @@ export class IgxDateRangePickerComponent extends DisplayDensityBase
516516
* @example
517517
* ```typescript
518518
* public selectFiveDayRange() {
519-
* const inFiveDays = new Date(new Date().setDate(today.getDate() + 5));
520519
* const today = new Date();
520+
* const inFiveDays = new Date(new Date().setDate(today.getDate() + 5));
521521
* this.dateRange.selectRange(today, inFiveDays);
522522
* }
523523
* ```
@@ -756,6 +756,9 @@ export class IgxDateRangePickerComponent extends DisplayDensityBase
756756
public handleSelection(selectionData: Date[]): void {
757757
this.value = this.extractRange(selectionData);
758758
this.rangeSelected.emit(this.value);
759+
if (this.mode === InteractionMode.DropDown && selectionData?.length > 1) {
760+
this.close();
761+
}
759762
}
760763

761764
protected onStatusChanged = () => {
@@ -955,7 +958,7 @@ export class IgxDateRangePickerComponent extends DisplayDensityBase
955958
closeAnimation: fadeOut
956959
};
957960
this._dropDownOverlaySettings.positionStrategy = new AutoPositionStrategy(this._positionSettings);
958-
this.dropdownOverlaySettings.target = this.element.nativeElement;
961+
this._dropDownOverlaySettings.target = this.element.nativeElement;
959962
}
960963

961964
private configOverlaySettings(): void {

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

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ describe('IgxRadioGroupDirective', () => {
1212
TestBed.configureTestingModule({
1313
declarations: [
1414
RadioGroupComponent,
15+
RadioGroupSimpleComponent,
1516
RadioGroupWithModelComponent,
1617
RadioGroupReactiveFormsComponent,
1718
RadioGroupDeepProjectionComponent
@@ -193,8 +194,37 @@ describe('IgxRadioGroupDirective', () => {
193194
expect(radioGroup.value).toEqual(0);
194195
expect(radioGroup.radioButtons.first.checked).toEqual(true);
195196
}));
197+
198+
it('Updates checked radio button correctly', fakeAsync(() => {
199+
const fixture = TestBed.createComponent(RadioGroupSimpleComponent);
200+
fixture.detectChanges();
201+
tick();
202+
203+
const radioGroup = fixture.componentInstance.radioGroup;
204+
expect(radioGroup.radioButtons.first.checked).toEqual(true);
205+
expect(radioGroup.radioButtons.last.checked).toEqual(false);
206+
207+
radioGroup.radioButtons.last.select();
208+
fixture.detectChanges();
209+
tick();
210+
211+
expect(radioGroup.radioButtons.first.checked).toEqual(false);
212+
expect(radioGroup.radioButtons.last.checked).toEqual(true);
213+
}));
196214
});
197215

216+
@Component({
217+
template: `
218+
<igx-radio-group #radioGroup>
219+
<igx-radio [checked]="true">Option 1</igx-radio>
220+
<igx-radio>Option 2</igx-radio>
221+
</igx-radio-group>
222+
`
223+
})
224+
class RadioGroupSimpleComponent {
225+
@ViewChild('radioGroup', { read: IgxRadioGroupDirective, static: true }) public radioGroup: IgxRadioGroupDirective;
226+
}
227+
198228
@Component({
199229
template: `<igx-radio-group #radioGroup name="radioGroup" value="Baz" required="true" labelPosition="before">
200230
<igx-radio *ngFor="let item of ['Foo', 'Bar', 'Baz']" value="{{item}}">

projects/igniteui-angular/src/lib/directives/radio/radio-group.directive.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -315,13 +315,11 @@ export class IgxRadioGroupDirective implements AfterContentInit, ControlValueAcc
315315
* @internal
316316
*/
317317
private _selectedRadioButtonChanged(args: IChangeRadioEventArgs) {
318-
if (this._selected !== args.radio) {
319-
if (this._selected) {
320-
this._selected.checked = false;
321-
}
322-
this._selected = args.radio;
323-
}
318+
this.radioButtons.forEach(button => {
319+
button.checked = button.id === args.radio.id;
320+
});
324321

322+
this._selected = args.radio;
325323
this._value = args.value;
326324

327325
if (this._isInitialized) {

projects/igniteui-angular/src/lib/grids/filtering/grid-filtering.service.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,9 +216,9 @@ export class IgxFilteringService implements OnDestroy {
216216
this.gridAPI.filter(field, value, expressionForColumn.condition, filteringIgnoreCase);
217217
}
218218
}
219-
219+
const eventArgs = this.grid.filteringExpressionsTree.find(field) as FilteringExpressionsTree;
220220
// Wait for the change detection to update filtered data through the pipes and then emit the event.
221-
requestAnimationFrame(() => this.grid.onFilteringDone.emit(col.filteringExpressionsTree));
221+
requestAnimationFrame(() => this.grid.onFilteringDone.emit(eventArgs));
222222
}
223223

224224
/**

projects/igniteui-angular/src/lib/grids/grid/grid-filtering.spec.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -649,6 +649,16 @@ describe('IgxGrid - Filtering actions #grid', () => {
649649
expect(grid.rowList.length).toEqual(1);
650650
}));
651651

652+
it('should exclude null and undefined values when filter by \'false\'', fakeAsync(() => {
653+
expect(grid.rowList.length).toEqual(8);
654+
655+
grid.filter('Released', false, IgxStringFilteringOperand.instance().condition('equals'), true);
656+
fix.detectChanges();
657+
expect(grid.rowList.length).toEqual(2);
658+
expect(grid.getCellByColumn(0, 'Released').value).toBe(false);
659+
expect(grid.getCellByColumn(1, 'Released').value).toBe(false);
660+
}));
661+
652662
it('should correctly apply multiple filtering through API', fakeAsync(() => {
653663
const gridExpressionsTree = new FilteringExpressionsTree(FilteringLogic.And);
654664
gridExpressionsTree.filteringOperands = [
@@ -895,6 +905,17 @@ describe('IgxGrid - Filtering actions #grid', () => {
895905
expect(grid.rowList.length).toEqual(2);
896906
}));
897907

908+
it('Should always emit onFilteringDone with proper eventArgs, even when column does not exist', fakeAsync(() => {
909+
spyOn(grid.onFilteringDone, 'emit');
910+
grid.filteringLogic = FilteringLogic.Or;
911+
grid.filter('Nonexisting', 'ignite', IgxStringFilteringOperand.instance().condition('contains'), true);
912+
tick(100);
913+
fix.detectChanges();
914+
expect(grid.rowList.length).toEqual(0);
915+
const args = grid.filteringExpressionsTree.find('Nonexisting') as FilteringExpressionsTree;
916+
expect(grid.onFilteringDone.emit).toHaveBeenCalledWith(args);
917+
}));
918+
898919
it('Should emit onFilteringDone when filtering globally', fakeAsync(() => {
899920
spyOn(grid.onFilteringDone, 'emit');
900921

0 commit comments

Comments
 (0)