@@ -1986,6 +1986,92 @@ describe('IgxGrid - Filtering Row UI actions #grid', () => {
19861986 const headerChip = GridFunctions . getFilterChipsForColumn ( 'ProductName' , fix ) ;
19871987 expect ( headerChip . length ) . toBe ( 1 ) ;
19881988 } ) ) ;
1989+
1990+ it ( 'Should commit the input and new chip after focus out and should edit chip without creating new one.' , fakeAsync ( ( ) => {
1991+ // Click date filter chip to show filter row.
1992+ const dateFilterCellChip = GridFunctions . getFilterChipsForColumn ( 'ReleaseDate' , fix ) [ 0 ] ;
1993+ dateFilterCellChip . nativeElement . click ( ) ;
1994+ tick ( 100 ) ;
1995+ fix . detectChanges ( ) ;
1996+
1997+ // Click input to open calendar.
1998+ const filteringRow = fix . debugElement . query ( By . directive ( IgxGridFilteringRowComponent ) ) ;
1999+ const inputDebugElement = filteringRow . query ( By . directive ( IgxInputDirective ) ) ;
2000+ const input = inputDebugElement . nativeElement ;
2001+ input . click ( ) ;
2002+ tick ( 100 ) ;
2003+ fix . detectChanges ( ) ;
2004+
2005+ // Click the today date.
2006+ const outlet = document . getElementsByClassName ( 'igx-grid__outlet' ) [ 0 ] ;
2007+ let calendar = outlet . getElementsByClassName ( 'igx-calendar' ) [ 0 ] ;
2008+ const todayDayItem : HTMLElement = calendar . querySelector ( '.igx-calendar__date--current' ) ;
2009+ todayDayItem . focus ( ) ;
2010+ todayDayItem . click ( ) ;
2011+ tick ( 100 ) ;
2012+ fix . detectChanges ( ) ;
2013+
2014+ // Verify the newly added chip is selected.
2015+ const chip = GridFunctions . getFilterConditionChip ( fix , 0 ) ;
2016+ const chipDiv = chip . querySelector ( '.igx-chip__item' ) ;
2017+
2018+ expect ( chipDiv . classList . contains ( 'igx-chip__item--selected' ) ) . toBe ( true , 'initial chip is committed' ) ;
2019+
2020+ // Focus out
2021+ grid . nativeElement . focus ( ) ;
2022+ grid . filteringRow . onInputGroupFocusout ( ) ;
2023+ tick ( 200 ) ;
2024+ fix . detectChanges ( ) ;
2025+
2026+ expect ( chipDiv . classList . contains ( 'igx-chip__item--selected' ) ) . toBe ( false , 'initial chip is not committed' ) ;
2027+ expect ( input . value ) . toBe ( '' , 'initial input value is present and not committed' ) ;
2028+
2029+ chip . click ( ) ;
2030+ tick ( 200 ) ;
2031+ fix . detectChanges ( ) ;
2032+
2033+ // Open calendar
2034+ input . click ( ) ;
2035+ tick ( 100 ) ;
2036+ fix . detectChanges ( ) ;
2037+
2038+ calendar = outlet . getElementsByClassName ( 'igx-calendar' ) [ 0 ] ;
2039+
2040+ // View years
2041+ const yearView : HTMLElement = calendar . querySelectorAll ( '.igx-calendar-picker__date' ) [ 1 ] as HTMLElement ;
2042+ yearView . click ( ) ;
2043+ tick ( 100 ) ;
2044+ fix . detectChanges ( ) ;
2045+
2046+ // Select the first year
2047+ const firstYear : HTMLElement = calendar . querySelectorAll ( '.igx-calendar__year' ) [ 0 ] as HTMLElement ;
2048+ firstYear . click ( ) ;
2049+ tick ( 100 ) ;
2050+ fix . detectChanges ( ) ;
2051+
2052+ // Select the first day
2053+ const firstDayItem : HTMLElement = calendar . querySelector ( '.igx-calendar__date' ) ;
2054+ firstDayItem . focus ( ) ;
2055+ firstDayItem . click ( ) ;
2056+ tick ( 100 ) ;
2057+ fix . detectChanges ( ) ;
2058+
2059+ expect ( chipDiv . classList . contains ( 'igx-chip__item--selected' ) ) . toBe ( true , 'chip is committed' ) ;
2060+
2061+ // Focus out
2062+ grid . nativeElement . focus ( ) ;
2063+ grid . filteringRow . onInputGroupFocusout ( ) ;
2064+ tick ( 200 ) ;
2065+ fix . detectChanges ( ) ;
2066+ expect ( chipDiv . classList . contains ( 'igx-chip__item--selected' ) ) . toBe ( false , 'chip is selected' ) ;
2067+
2068+ // Check if we still have only one committed chip
2069+ const chipsLength = GridFunctions . getAllFilterConditionChips ( fix ) . length ;
2070+
2071+ expect ( chipsLength ) . toBe ( 1 , 'there is more than one chip' ) ;
2072+ expect ( chipDiv . classList . contains ( 'igx-chip__item--selected' ) ) . toBe ( false , 'chip is not committed' ) ;
2073+ expect ( input . value ) . toBe ( '' , 'input value is present and not committed' ) ;
2074+ } ) ) ;
19892075 } ) ;
19902076
19912077 describe ( 'Integration scenarios' , ( ) => {
0 commit comments