Skip to content

Commit 5759289

Browse files
authored
Merge branch 'master' into mkirova/change-events
2 parents df5283c + 4715b6a commit 5759289

File tree

10 files changed

+151
-62
lines changed

10 files changed

+151
-62
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ For more information about the theming please read our [documentation](https://w
6464
- introduced a new `readonly` property that doesn't allow user interaction to change the state, but keeps the default active style. Intended for integration in complex controls that handle the interaction and control the checkbox instead through binding.
6565
- `IgxOverlay`
6666
- introduced a new `ContainerPositionStrategy`. The new strategy positions the element inside the containing outlet based on the directions passed in trough PositionSettings.
67+
- `IgxChip`
68+
- add `onSelectionDone` event that is triggered after all animations and transitions related to selection have ended.
6769

6870
### General
6971
- `IgxGrid`, `IgxTreeGrid`, `IgxHierarchicalGrid`

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
(enter)="onChipDragEnterHandler($event)"
1313
(dropped)="onChipDrop($event)">
1414

15-
<div [ngClass]="selectClass(selected)">
15+
<div [ngClass]="selectClass(selected)" (transitionend)="onSelectTransitionDone($event)">
1616
<ng-container *ngTemplateOutlet="selectIconTemplate"></ng-container>
1717
</div>
1818

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

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,12 +292,26 @@ export class IgxChipComponent extends DisplayDensityBase {
292292
* }
293293
* ```
294294
* ```html
295-
* <igx-chip #myChip [id]="'igx-chip-1'" [draggable]="true" (onSelection)="chipSelect($event)">
295+
* <igx-chip #myChip [id]="'igx-chip-1'" [selectable]="true" (onSelection)="chipSelect($event)">
296296
* ```
297297
*/
298298
@Output()
299299
public onSelection = new EventEmitter<IChipSelectEventArgs>();
300300

301+
/**
302+
* Emits event when the `IgxChipComponent` is selected/deselected and any related animations and transitions also end.
303+
* ```typescript
304+
* chipSelectEnd(event: IBaseChipEventArgs){
305+
* let selectedChip = event.owner;
306+
* }
307+
* ```
308+
* ```html
309+
* <igx-chip #myChip [id]="'igx-chip-1'" [selectable]="true" (onSelectionDone)="chipSelectEnd($event)">
310+
* ```
311+
*/
312+
@Output()
313+
public onSelectionDone = new EventEmitter<IBaseChipEventArgs>();
314+
301315
/**
302316
* Emits an event when the `IgxChipComponent` keyboard navigation is being used.
303317
* Returns the focused/selected `IgxChipComponent`, whether the event should be canceled,
@@ -448,6 +462,16 @@ export class IgxChipComponent extends DisplayDensityBase {
448462
}
449463
}
450464

465+
public onSelectTransitionDone(event) {
466+
if (event.propertyName === 'width' && !!event.target.tagName) {
467+
// Trigger onSelectionDone on when `width` property is changed and the target is valid element(not comment).
468+
this.onSelectionDone.emit({
469+
owner: this,
470+
originalEvent: event
471+
});
472+
}
473+
}
474+
451475
/**
452476
* @hidden
453477
*/

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

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { IgxPrefixDirective } from './../directives/prefix/prefix.directive';
1313
import { IgxLabelDirective } from './../directives/label/label.directive';
1414
import { IgxSuffixDirective } from './../directives/suffix/suffix.directive';
1515
import { DisplayDensity } from '../core/displayDensity';
16-
import { UIInteractions} from '../test-utils/ui-interactions.spec';
16+
import { UIInteractions, wait} from '../test-utils/ui-interactions.spec';
1717
import { configureTestSuite } from '../test-utils/configure-suite';
1818

1919
@Component({
@@ -398,13 +398,14 @@ describe('IgxChip', () => {
398398
});
399399
});
400400

401-
it('should fire onSelection event when selectable is true', () => {
401+
it('should fire onSelection event when selectable is true', (async() => {
402402
const fix = TestBed.createComponent(TestChipComponent);
403403
fix.detectChanges();
404404

405405
const secondChipComp = fix.componentInstance.chips.toArray()[1];
406406

407407
spyOn(secondChipComp.onSelection, 'emit');
408+
spyOn(secondChipComp.onSelectionDone, 'emit');
408409
secondChipComp.chipArea.nativeElement.focus();
409410

410411
const keyEvent = new KeyboardEvent('keydown', {
@@ -413,7 +414,11 @@ describe('IgxChip', () => {
413414
secondChipComp.chipArea.nativeElement.dispatchEvent(keyEvent);
414415
fix.detectChanges();
415416
expect(secondChipComp.onSelection.emit).toHaveBeenCalled();
416-
});
417+
expect(secondChipComp.onSelectionDone.emit).not.toHaveBeenCalled();
418+
419+
await wait(400);
420+
expect(secondChipComp.onSelectionDone.emit).toHaveBeenCalled();
421+
}));
417422

418423
it('should not fire onSelection event when selectable is false', () => {
419424
const fix = TestBed.createComponent(TestChipComponent);
@@ -422,6 +427,7 @@ describe('IgxChip', () => {
422427
const firstChipComp = fix.componentInstance.chips.toArray()[0];
423428

424429
spyOn(firstChipComp.onSelection, 'emit');
430+
spyOn(firstChipComp.onSelectionDone, 'emit');
425431
firstChipComp.elementRef.nativeElement.focus();
426432

427433
const keyEvent = new KeyboardEvent('keydown', {
@@ -430,6 +436,7 @@ describe('IgxChip', () => {
430436
firstChipComp.elementRef.nativeElement.dispatchEvent(keyEvent);
431437
fix.detectChanges();
432438
expect(firstChipComp.onSelection.emit).toHaveBeenCalledTimes(0);
439+
expect(firstChipComp.onSelectionDone.emit).toHaveBeenCalledTimes(0);
433440
});
434441

435442
it('should not fire onSelection event when the remove button is clicked', () => {
@@ -439,6 +446,7 @@ describe('IgxChip', () => {
439446
const secondChipComp = fix.componentInstance.chips.toArray()[1];
440447

441448
spyOn(secondChipComp.onSelection, 'emit');
449+
spyOn(secondChipComp.onSelectionDone, 'emit');
442450

443451
const chipRemoveButton = secondChipComp.elementRef.nativeElement.querySelectorAll('.' + CHIP_REMOVE_BUTTON)[0];
444452
const removeBtnTop = chipRemoveButton.getBoundingClientRect().top;
@@ -450,5 +458,6 @@ describe('IgxChip', () => {
450458
fix.detectChanges();
451459

452460
expect(secondChipComp.onSelection.emit).not.toHaveBeenCalled();
461+
expect(secondChipComp.onSelectionDone.emit).not.toHaveBeenCalled();
453462
});
454463
});

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
<igx-icon>today</igx-icon>
1616
</igx-prefix>
1717
<label *ngIf="labelVisibility" igxLabel>{{label}}</label>
18-
<input #editableInput class="igx-date-picker__input-date" igxInput type="text" [value]="transformedDate"
18+
<input #editableInput class="igx-date-picker__input-date" igxInput [igxTextSelection]="true"
19+
type="text" [value]="transformedDate"
1920
[igxMask]="inputMask" [placeholder]="mask" [disabled]="disabled" [displayValuePipe]="displayValuePipe"
2021
[focusedValuePipe]="inputValuePipe" (blur)="onBlur($event)" (wheel)="onWheel($event)"
2122
(input)="onInput($event)" (focus)="onFocus()" />
@@ -25,4 +26,4 @@
2526
</igx-input-group>
2627
</ng-template>
2728

28-
<ng-container *ngTemplateOutlet="template; context: context"></ng-container>
29+
<ng-container *ngTemplateOutlet="template; context: context"></ng-container>

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

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { IgxLabelDirective } from '../directives/label/label.directive';
88
import { IgxInputDirective } from '../directives/input/input.directive';
99
import { UIInteractions, wait } from '../test-utils/ui-interactions.spec';
1010
import { IgxInputGroupModule } from '../input-group';
11-
11+
import { IgxTextSelectionModule } from '../directives/text-selection/text-selection.directive';
1212
import { configureTestSuite } from '../test-utils/configure-suite';
1313
import { DateRangeType } from 'igniteui-angular';
1414
import { IgxButtonModule } from '../directives/button/button.directive';
@@ -32,7 +32,8 @@ describe('IgxDatePicker', () => {
3232
IgxDropDownDatePickerRetemplatedComponent,
3333
IgxDatePickerOpeningComponent
3434
],
35-
imports: [IgxDatePickerModule, FormsModule, NoopAnimationsModule, IgxInputGroupModule, IgxCalendarModule, IgxButtonModule]
35+
imports: [IgxDatePickerModule, FormsModule, NoopAnimationsModule, IgxInputGroupModule, IgxCalendarModule,
36+
IgxButtonModule, IgxTextSelectionModule]
3637
})
3738
.compileComponents();
3839
}));
@@ -1089,6 +1090,29 @@ describe('IgxDatePicker', () => {
10891090
expect(instance.getEditElement()).toBe(editElement);
10901091
});
10911092
});
1093+
1094+
describe('Drop-down mode select all text on focus', () => {
1095+
let fixture: ComponentFixture<IgxDatePickerEditableComponent>;
1096+
let datePicker: IgxDatePickerComponent;
1097+
1098+
beforeEach(() => {
1099+
fixture = TestBed.createComponent(IgxDatePickerEditableComponent);
1100+
datePicker = fixture.componentInstance.datePicker;
1101+
fixture.detectChanges();
1102+
});
1103+
1104+
it('Should select all input text on input focus', fakeAsync(() => {
1105+
const input = fixture.debugElement.query(By.directive(IgxInputDirective)).nativeElement;
1106+
input.focus();
1107+
fixture.detectChanges();
1108+
tick(100);
1109+
1110+
expect(input).toEqual(document.activeElement);
1111+
expect(input.selectionEnd).toEqual(input.value.length);
1112+
expect(input.selectionStart).toEqual(0);
1113+
expect(input.value.substring(input.selectionStart, input.selectionEnd)).toEqual(input.value);
1114+
}));
1115+
});
10921116
});
10931117

10941118
@Component({

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import { IgxInputGroupModule, IgxInputDirective, IgxInputGroupComponent } from '
3232
import { Subject, fromEvent, animationFrameScheduler, interval } from 'rxjs';
3333
import { filter, takeUntil, throttle } from 'rxjs/operators';
3434
import { IgxOverlayOutletDirective } from '../directives/toggle/toggle.directive';
35+
import { IgxTextSelectionModule} from '../directives/text-selection/text-selection.directive';
3536
import {
3637
OverlaySettings,
3738
IgxOverlayService,
@@ -1379,7 +1380,8 @@ export class IgxDatePickerComponent implements IDatePicker, ControlValueAccessor
13791380
IgxDatePickerTemplateDirective, DatePickerDisplayValuePipe, DatePickerInputValuePipe],
13801381
exports: [IgxDatePickerComponent, IgxDatePickerTemplateDirective, IgxDatePickerActionsDirective,
13811382
DatePickerDisplayValuePipe, DatePickerInputValuePipe],
1382-
imports: [CommonModule, IgxIconModule, IgxInputGroupModule, IgxCalendarModule, IgxButtonModule, IgxRippleModule, IgxMaskModule],
1383+
imports: [CommonModule, IgxIconModule, IgxInputGroupModule, IgxCalendarModule, IgxButtonModule,
1384+
IgxRippleModule, IgxMaskModule, IgxTextSelectionModule],
13831385
entryComponents: [IgxCalendarContainerComponent]
13841386
})
13851387
export class IgxDatePickerModule { }

projects/igniteui-angular/src/lib/grids/filtering/advanced-filtering/advanced-filtering-dialog.component.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ <h6 class="igx-filter-empty__title">
9494
(click)="onChipClick(expressionItem)"
9595
(dblclick)="onChipDblClick(expressionItem)"
9696
(onRemove)="onChipRemove(expressionItem)"
97+
(onSelectionDone)="onChipSelectionEnd()"
9798
>
9899
<span igxPrefix class="igx-filter-tree__expression-column">{{ expressionItem.expression.fieldName }}</span>
99100
<igx-icon

projects/igniteui-angular/src/lib/grids/filtering/advanced-filtering/advanced-filtering-dialog.component.ts

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -538,15 +538,6 @@ export class IgxAdvancedFilteringDialogComponent implements AfterViewInit, OnDes
538538
}
539539
];
540540
}
541-
542-
setTimeout(() => {
543-
this.calculateContextMenuTarget();
544-
if (this.contextMenuToggle.collapsed) {
545-
this.contextMenuToggle.open(this._overlaySettings);
546-
} else {
547-
this.contextMenuToggle.reposition();
548-
}
549-
}, 200);
550541
} else {
551542
this.contextMenuToggle.close();
552543
}
@@ -832,4 +823,17 @@ export class IgxAdvancedFilteringDialogComponent implements AfterViewInit, OnDes
832823
this.applyChanges();
833824
this.closeDialog();
834825
}
826+
827+
public onChipSelectionEnd() {
828+
const contextualGroup = this.findSingleSelectedGroup();
829+
if (contextualGroup || this.selectedExpressions.length > 1) {
830+
this.contextualGroup = contextualGroup;
831+
this.calculateContextMenuTarget();
832+
if (this.contextMenuToggle.collapsed) {
833+
this.contextMenuToggle.open(this._overlaySettings);
834+
} else {
835+
this.contextMenuToggle.reposition();
836+
}
837+
}
838+
}
835839
}

0 commit comments

Comments
 (0)