@@ -79,13 +79,8 @@ export class IgxGridFilteringRowComponent implements AfterViewInit {
7979 this . _column = val ;
8080
8181 this . expressionsList = this . filteringService . getExpressions ( this . _column . field ) ;
82- const selectedChip = this . expressionsList . find ( ex => ex . isSelected ) ;
8382
84- if ( selectedChip ) {
85- this . expression = selectedChip . expression ;
86- } else {
8783 this . resetExpression ( ) ;
88- }
8984
9085 this . chipAreaScrollOffset = 0 ;
9186 this . transform ( this . chipAreaScrollOffset ) ;
@@ -369,8 +364,8 @@ export class IgxGridFilteringRowComponent implements AfterViewInit {
369364 * Commits the value of the input.
370365 */
371366 public commitInput ( ) {
372- const selectedChip = this . expressionsList . filter ( ex => ex . isSelected === true ) ;
373- selectedChip . forEach ( e => e . isSelected = false ) ;
367+ this . expressionsList . forEach ( ex => ex . isSelected = false ) ;
368+ this . chipsArea . chipsList . forEach ( chip => chip . selected = false ) ;
374369
375370 let indexToDeselect = - 1 ;
376371 for ( let index = 0 ; index < this . expressionsList . length ; index ++ ) {
@@ -391,8 +386,6 @@ export class IgxGridFilteringRowComponent implements AfterViewInit {
391386 */
392387 public clearInput ( ) {
393388 this . value = null ;
394- const selectedChip = this . expressionsList . findIndex ( ex => ex . isSelected === true ) ;
395- this . expressionsList . splice ( selectedChip , 1 ) ;
396389 }
397390
398391 /**
@@ -442,8 +435,8 @@ export class IgxGridFilteringRowComponent implements AfterViewInit {
442435 }
443436 requestAnimationFrame ( ( ) => {
444437 const focusedElement = document . activeElement ;
445- if ( ! ( focusedElement && this . inputGroup . nativeElement . contains ( focusedElement ) )
446- && this . dropDownConditions . collapsed ) {
438+ if ( ! ( focusedElement && this . inputGroup . nativeElement . contains ( focusedElement ) ) &&
439+ this . dropDownConditions . collapsed ) {
447440 this . commitInput ( ) ;
448441 }
449442 } ) ;
@@ -534,53 +527,44 @@ export class IgxGridFilteringRowComponent implements AfterViewInit {
534527 this . _cancelChipClick = chip . selected && activeElement && this . inputGroup . nativeElement . contains ( activeElement ) ;
535528 }
536529
537- public onChipClick ( args , item : ExpressionUI ) {
530+ public onChipClick ( args , chip : IgxChipComponent ) {
538531 if ( this . _cancelChipClick ) {
539532 return ;
540533 }
541534
542535 this . _cancelChipClick = false ;
543- item . isSelected = ! item . isSelected ;
536+ chip . selected = ! chip . selected ;
537+ }
544538
545- if ( item . isSelected ) {
546- if ( this . expressionsList ) {
547- this . expressionsList . forEach ( ( expr ) => {
548- if ( expr !== item ) {
549- expr . isSelected = false ;
539+ /**
540+ * Event handler for chip selected event.
541+ */
542+ public onChipSelected ( eventArgs : IChipSelectEventArgs , expression : IFilteringExpression ) {
543+ if ( eventArgs . selected ) {
544+ if ( this . chipsArea . chipsList ) {
545+ this . chipsArea . chipsList . forEach ( ( chip ) => {
546+ if ( chip !== eventArgs . owner ) {
547+ chip . selected = false ;
550548 }
551549 } ) ;
552550 }
553- this . expression = item . expression ;
551+ this . expression = expression ;
554552
555553 if ( this . input ) {
556554 this . input . nativeElement . focus ( ) ;
557555 }
558- } else if ( this . expression === item . expression ) {
556+ } else if ( this . expression === expression ) {
559557 this . resetExpression ( ) ;
560558 }
561559 }
562560
563- /**
564- * Event handler for chip selected event.
565- */
566- public onChipSelected ( eventArgs : IChipSelectEventArgs ) {
567- if ( eventArgs . selected && this . input ) {
568- this . input . nativeElement . focus ( ) ;
569- }
570- }
571-
572561 /**
573562 * Event handler for chip keydown event.
574563 */
575- public onChipKeyDown ( eventArgs : KeyboardEvent , item : ExpressionUI ) {
564+ public onChipKeyDown ( eventArgs : KeyboardEvent , chip : IgxChipComponent ) {
576565 if ( eventArgs . key === KEYS . ENTER ) {
577566 eventArgs . preventDefault ( ) ;
578- item . isSelected = ! item . isSelected ;
579-
580- this . expression = item . expression ;
581- if ( this . input ) {
582- this . input . nativeElement . focus ( ) ;
583- }
567+ chip . selected = ! chip . selected ;
584568 }
585569 }
586570
0 commit comments