@@ -79,8 +79,13 @@ 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 ) ;
8283
84+ if ( selectedChip ) {
85+ this . expression = selectedChip . expression ;
86+ } else {
8387 this . resetExpression ( ) ;
88+ }
8489
8590 this . chipAreaScrollOffset = 0 ;
8691 this . transform ( this . chipAreaScrollOffset ) ;
@@ -364,8 +369,8 @@ export class IgxGridFilteringRowComponent implements AfterViewInit {
364369 * Commits the value of the input.
365370 */
366371 public commitInput ( ) {
367- this . expressionsList . forEach ( ex => ex . isSelected = false ) ;
368- this . chipsArea . chipsList . forEach ( chip => chip . selected = false ) ;
372+ const selectedChip = this . expressionsList . filter ( ex => ex . isSelected === true ) ;
373+ selectedChip . forEach ( e => e . isSelected = false ) ;
369374
370375 let indexToDeselect = - 1 ;
371376 for ( let index = 0 ; index < this . expressionsList . length ; index ++ ) {
@@ -386,6 +391,8 @@ export class IgxGridFilteringRowComponent implements AfterViewInit {
386391 */
387392 public clearInput ( ) {
388393 this . value = null ;
394+ const selectedChip = this . expressionsList . findIndex ( ex => ex . isSelected === true ) ;
395+ this . expressionsList . splice ( selectedChip , 1 ) ;
389396 }
390397
391398 /**
@@ -435,8 +442,8 @@ export class IgxGridFilteringRowComponent implements AfterViewInit {
435442 }
436443 requestAnimationFrame ( ( ) => {
437444 const focusedElement = document . activeElement ;
438- if ( ! ( focusedElement && this . inputGroup . nativeElement . contains ( focusedElement ) ) &&
439- this . dropDownConditions . collapsed ) {
445+ if ( ! ( focusedElement && this . inputGroup . nativeElement . contains ( focusedElement ) )
446+ && this . dropDownConditions . collapsed ) {
440447 this . commitInput ( ) ;
441448 }
442449 } ) ;
@@ -527,44 +534,53 @@ export class IgxGridFilteringRowComponent implements AfterViewInit {
527534 this . _cancelChipClick = chip . selected && activeElement && this . inputGroup . nativeElement . contains ( activeElement ) ;
528535 }
529536
530- public onChipClick ( args , chip : IgxChipComponent ) {
537+ public onChipClick ( args , item : ExpressionUI ) {
531538 if ( this . _cancelChipClick ) {
532539 return ;
533540 }
534541
535542 this . _cancelChipClick = false ;
536- chip . selected = ! chip . selected ;
537- }
543+ item . isSelected = ! item . isSelected ;
538544
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 ;
545+ if ( item . isSelected ) {
546+ if ( this . expressionsList ) {
547+ this . expressionsList . forEach ( ( expr ) => {
548+ if ( expr !== item ) {
549+ expr . isSelected = false ;
548550 }
549551 } ) ;
550552 }
551- this . expression = expression ;
553+ this . expression = item . expression ;
552554
553555 if ( this . input ) {
554556 this . input . nativeElement . focus ( ) ;
555557 }
556- } else if ( this . expression === expression ) {
558+ } else if ( this . expression === item . expression ) {
557559 this . resetExpression ( ) ;
558560 }
559561 }
560562
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+
561572 /**
562573 * Event handler for chip keydown event.
563574 */
564- public onChipKeyDown ( eventArgs : KeyboardEvent , chip : IgxChipComponent ) {
575+ public onChipKeyDown ( eventArgs : KeyboardEvent , item : ExpressionUI ) {
565576 if ( eventArgs . key === KEYS . ENTER ) {
566577 eventArgs . preventDefault ( ) ;
567- chip . selected = ! chip . selected ;
578+ item . isSelected = ! item . isSelected ;
579+
580+ this . expression = item . expression ;
581+ if ( this . input ) {
582+ this . input . nativeElement . focus ( ) ;
583+ }
568584 }
569585 }
570586
0 commit comments