Skip to content

Commit e0228c9

Browse files
authored
Merge pull request #6266 from IgniteUI/SKrastev/fix-6183-master
fix(chips): Fix chips displaying initial transition on the selection icon.
2 parents 9a5aceb + 4492a6a commit e0228c9

File tree

4 files changed

+20
-11
lines changed

4 files changed

+20
-11
lines changed

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

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

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ import {
2121
IDropDroppedEventArgs
2222
} from '../directives/drag-drop/drag-drop.directive';
2323
import { IBaseEventArgs } from '../core/utils';
24+
import { fromEvent } from 'rxjs';
25+
import { take, filter } from 'rxjs/operators';
2426

2527

2628
export interface IBaseChipEventArgs extends IBaseEventArgs {
@@ -376,6 +378,12 @@ export class IgxChipComponent extends DisplayDensityBase {
376378
@ViewChild('chipArea', { read: ElementRef, static: true })
377379
public chipArea: ElementRef;
378380

381+
/**
382+
* @hidden
383+
*/
384+
@ViewChild('selectContainer', { read: ElementRef, static: true })
385+
public selectContainer: ElementRef;
386+
379387
/**
380388
* @hidden
381389
*/
@@ -442,6 +450,10 @@ export class IgxChipComponent extends DisplayDensityBase {
442450
cancel: false
443451
};
444452

453+
fromEvent(this.selectContainer.nativeElement, 'transitionend')
454+
.pipe(filter<TransitionEvent>(event => event.propertyName === 'width'), take(1))
455+
.subscribe(event => this.onSelectTransitionDone(event));
456+
445457
if (newValue && !this._selected) {
446458
onSelectArgs.selected = true;
447459
this.onSelection.emit(onSelectArgs);
@@ -463,7 +475,7 @@ export class IgxChipComponent extends DisplayDensityBase {
463475
}
464476

465477
public onSelectTransitionDone(event) {
466-
if (event.propertyName === 'width' && !!event.target.tagName) {
478+
if (!!event.target.tagName) {
467479
// Trigger onSelectionDone on when `width` property is changed and the target is valid element(not comment).
468480
this.onSelectionDone.emit({
469481
owner: this,

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@ describe('IgxChip', () => {
423423
});
424424

425425
await wait(400);
426-
expect(secondChipComp.onSelectionDone.emit).toHaveBeenCalled();
426+
expect(secondChipComp.onSelectionDone.emit).toHaveBeenCalledTimes(1);
427427
expect(secondChipComp.onSelectionDone.emit).not.toHaveBeenCalledWith({
428428
originalEvent: null,
429429
owner: secondChipComp

projects/igniteui-angular/src/lib/core/styles/components/chip/_chip-theme.scss

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -430,13 +430,13 @@
430430
%igx-chip__select {
431431
display: inline-flex;
432432
align-items: center;
433-
z-index: 1;
433+
width: 18px;
434434
opacity: 1;
435-
transition: opacity 120ms $ease-in-out-quad;
435+
z-index: 1;
436+
transition: opacity 120ms $ease-out-quad, width 120ms $ease-out-quad;
436437

437438
> * {
438-
width: 18px !important;
439-
transition: width 120ms $ease-in-out-quad;
439+
width: inherit !important;
440440
}
441441

442442
+ igx-prefix,
@@ -446,13 +446,10 @@
446446
}
447447

448448
%igx-chip__select--hidden {
449+
width: 0;
449450
opacity: 0;
450451
z-index: -1;
451452

452-
> * {
453-
width: 0 !important;
454-
}
455-
456453
+ igx-prefix,
457454
+ [igxPrefix] {
458455
margin-#{$left}: 0;

0 commit comments

Comments
 (0)