Skip to content

Commit eb42587

Browse files
authored
Merge branch 'master' into tzhelev/gridSearch-exactMatch
2 parents 69527c4 + e9c8023 commit eb42587

File tree

9 files changed

+235
-20
lines changed

9 files changed

+235
-20
lines changed

package-lock.json

Lines changed: 21 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

projects/igniteui-angular/src/lib/chips/chip.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ export class IgxChipComponent implements AfterViewInit {
317317
nextStatus: false,
318318
cancel: false
319319
};
320-
if (newValue && this.selectable && !this._selected) {
320+
if (newValue && !this._selected) {
321321
onSelectArgs.nextStatus = true;
322322
this.onSelection.emit(onSelectArgs);
323323

projects/igniteui-angular/src/lib/chips/chips-area.component.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,14 +176,15 @@ export class IgxChipsAreaComponent implements DoCheck {
176176
let orderChanged = false;
177177
const chipsArray = this.chipsList.toArray();
178178
const dragChipIndex = chipsArray.findIndex((el) => el === event.owner);
179-
180179
if (event.shiftKey === true) {
181180
if (event.key === 'ArrowLeft' || event.key === 'Left') {
182181
orderChanged = this.positionChipAtIndex(dragChipIndex, dragChipIndex - 1, false);
183182
if (orderChanged) {
183+
// The `modifiedChipsArray` is out of date in the setTimeout sometimes.
184+
const chipArray = this.modifiedChipsArray;
184185
setTimeout(() => {
185-
this.modifiedChipsArray[dragChipIndex - 1].chipArea.nativeElement.focus();
186-
}, 0);
186+
chipArray[dragChipIndex - 1].chipArea.nativeElement.focus();
187+
});
187188
}
188189
} else if (event.key === 'ArrowRight' || event.key === 'Right') {
189190
orderChanged = this.positionChipAtIndex(dragChipIndex, dragChipIndex + 1, true);

projects/igniteui-angular/src/lib/chips/chips-area.spec.ts

Lines changed: 70 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ChipsSampleComponent } from './../../../../../src/app/chips/chips.sample';
1+
import { ChipsSampleComponent } from './../../../../../src/app/chips/chips.sample';
22
import { Component, ViewChild, ViewChildren, QueryList } from '@angular/core';
33
import {
44
async,
@@ -555,6 +555,17 @@ describe('IgxChipsArea', () => {
555555
});
556556
});
557557

558+
it('should be able to select chip using api when selectable is set to false', () => {
559+
const fix = TestBed.createComponent(TestChipComponent);
560+
fix.detectChanges();
561+
562+
const selectedChip = fix.componentInstance.chipsArea.chipsList.toArray()[0];
563+
selectedChip.selected = true;
564+
fix.detectChanges();
565+
566+
expect(selectedChip.selected).toBe(true);
567+
});
568+
558569
it('should focus on chip correctly', () => {
559570
const fix = TestBed.createComponent(TestChipComponent);
560571
fix.detectChanges();
@@ -600,7 +611,7 @@ describe('IgxChipsArea', () => {
600611
expect(document.activeElement).toBe(firstChipComp.chipArea.nativeElement);
601612
});
602613

603-
it('should reorder chips when shift + leftarrow and shift + rightarrow is pressed', () => {
614+
it('should reorder chips when shift + leftarrow and shift + rightarrow is pressed', async(() => {
604615
const leftKey = new KeyboardEvent('keydown', {
605616
'key': 'ArrowLeft',
606617
shiftKey: true
@@ -651,9 +662,61 @@ describe('IgxChipsArea', () => {
651662
expect(firstChipLeft).toEqual(newFirstChipLeft);
652663
expect(newSecondChipLeft).toEqual(secondChipLeft);
653664
});
654-
});
665+
}));
666+
667+
it('should reorder chips when shift + leftarrow is pressed and shift + rightarrow is pressed twice', async(() => {
668+
const fix = TestBed.createComponent(TestChipReorderComponent);
669+
fix.detectChanges();
670+
671+
const leftKey = new KeyboardEvent('keydown', {
672+
'key': 'ArrowLeft',
673+
shiftKey: true
674+
});
675+
const rightKey = new KeyboardEvent('keydown', {
676+
'key': 'ArrowRight',
677+
shiftKey: true
678+
});
679+
const chipAreaComponent = fix.componentInstance.chipsArea;
680+
const chipComponents = fix.debugElement.queryAll(By.directive(IgxChipComponent));
681+
const targetChip = chipComponents[2].componentInstance;
682+
const targetChipElem = targetChip.chipArea.nativeElement;
683+
684+
targetChipElem.focus();
685+
fix.detectChanges();
686+
687+
expect(document.activeElement).toBe(targetChipElem);
688+
expect(chipAreaComponent.chipsList.toArray()[2].id).toEqual('Town');
689+
expect(chipAreaComponent.chipsList.toArray()[3].id).toEqual('FirstName');
690+
691+
document.activeElement.dispatchEvent(rightKey);
692+
fix.detectChanges();
693+
694+
fix.whenStable().then(() => {
695+
expect(document.activeElement).toBe(targetChipElem);
696+
expect(chipAreaComponent.chipsList.toArray()[2].id).toEqual('FirstName');
697+
expect(chipAreaComponent.chipsList.toArray()[3].id).toEqual('Town');
698+
699+
document.activeElement.dispatchEvent(leftKey);
700+
fix.detectChanges();
701+
702+
return fix.whenStable();
703+
}).then(() => {
704+
expect(document.activeElement).toBe(targetChipElem);
705+
expect(chipAreaComponent.chipsList.toArray()[2].id).toEqual('Town');
706+
expect(chipAreaComponent.chipsList.toArray()[3].id).toEqual('FirstName');
655707

656-
it('should not reorder chips when shift + leftarrow and shift + rightarrow is pressed when the chip is going out of bounce', () => {
708+
document.activeElement.dispatchEvent(leftKey);
709+
fix.detectChanges();
710+
711+
return fix.whenStable();
712+
}).then(() => {
713+
expect(document.activeElement).toBe(targetChipElem);
714+
expect(chipAreaComponent.chipsList.toArray()[2].id).toEqual('City');
715+
expect(chipAreaComponent.chipsList.toArray()[3].id).toEqual('FirstName');
716+
});
717+
}));
718+
719+
it('should not reorder chips for shift + leftarrow and shift + rightarrow when the chip is going out of bounce', async(() => {
657720
const leftKey = new KeyboardEvent('keydown', {
658721
'key': 'ArrowLeft',
659722
shiftKey: true
@@ -694,7 +757,7 @@ describe('IgxChipsArea', () => {
694757
expect(firstChipLeft).toEqual(newFirstChipLeft);
695758
expect(newlastChipLeft).toEqual(lastChipLeft);
696759
});
697-
});
760+
}));
698761

699762
it('should delete chip when delete button is pressed and chip is removable', () => {
700763
const deleteKey = new KeyboardEvent('keydown', {
@@ -736,7 +799,7 @@ describe('IgxChipsArea', () => {
736799
expect(chipComponents.length).toEqual(3);
737800
});
738801

739-
it('chip should persist selected state when it is dragged and dropped', () => {
802+
it('chip should persist selected state when it is dragged and dropped', async(() => {
740803
const spaceKeyEvent = new KeyboardEvent('keydown', {
741804
'key': ' '
742805
});
@@ -786,7 +849,7 @@ describe('IgxChipsArea', () => {
786849
const firstChip = chipComponents[0].componentInstance;
787850
expect(firstChip.selected).not.toBeTruthy();
788851
});
789-
});
852+
}));
790853

791854
it('should not fire any event of the chip area when attempting deleting of a chip', () => {
792855
const fix = TestBed.createComponent(TestChipComponent);

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
@@ -58,6 +58,7 @@ let NEXT_ID = 0;
5858
[{ provide: NG_VALUE_ACCESSOR, useExisting: IgxDatePickerComponent, multi: true }],
5959
// tslint:disable-next-line:component-selector
6060
selector: 'igx-datePicker',
61+
styles: [':host {display: block;}'],
6162
templateUrl: 'date-picker.component.html'
6263
})
6364
export class IgxDatePickerComponent implements ControlValueAccessor, OnInit, OnDestroy {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ export class IgxInputDirective implements AfterViewInit, OnDestroy {
155155
*/
156156
ngAfterViewInit() {
157157
this.inputGroup.hasPlaceholder = this.nativeElement.hasAttribute('placeholder');
158-
this.inputGroup.disabled = this.nativeElement.hasAttribute('disabled');
158+
this.inputGroup.disabled = this.inputGroup.disabled || this.nativeElement.hasAttribute('disabled');
159159
this.inputGroup.isRequired = this.nativeElement.hasAttribute('required');
160160

161161
// Also check the control's validators for required

0 commit comments

Comments
 (0)