@@ -1355,31 +1355,6 @@ describe('IgxGrid - Filtering Row UI actions #grid', () => {
13551355 verifyFilterRowUI ( input , close , reset ) ;
13561356 } ) ) ;
13571357
1358- it ( 'Should commit the input and new chip after picking date from calendar for filtering.' , fakeAsync ( ( ) => {
1359- GridFunctions . clickFilterCellChip ( fix , 'ReleaseDate' ) ;
1360-
1361- // Click input to open calendar.
1362- const filteringRow = fix . debugElement . query ( By . directive ( IgxGridFilteringRowComponent ) ) ;
1363- const input = filteringRow . query ( By . directive ( IgxInputDirective ) ) ;
1364- input . triggerEventHandler ( 'click' , null ) ;
1365- tick ( 100 ) ;
1366- fix . detectChanges ( ) ;
1367-
1368- // Click the today date.
1369- const outlet = document . getElementsByClassName ( 'igx-grid__outlet' ) [ 0 ] ;
1370- const calendar = outlet . getElementsByClassName ( 'igx-calendar' ) [ 0 ] ;
1371- const todayDayItem = calendar . querySelector ( '.igx-calendar__date--current' ) ;
1372- ( < HTMLElement > todayDayItem ) . click ( ) ;
1373- tick ( 200 ) ;
1374- fix . detectChanges ( ) ;
1375-
1376- // Verify the chip and input are committed.
1377- const filterChip = filteringRow . query ( By . directive ( IgxChipComponent ) ) ;
1378- expect ( filterChip ) . toBeTruthy ( ) ;
1379- expect ( filterChip . componentInstance . selected ) . toBeFalsy ( ) ;
1380- expect ( input . nativeElement . value ) . toEqual ( '' ) ;
1381- } ) ) ;
1382-
13831358 it ( 'Should navigate keyboard focus correctly between the filter row and the grid cells.' , fakeAsync ( ( ) => {
13841359 GridFunctions . clickFilterCellChip ( fix , 'ProductName' ) ;
13851360
@@ -1986,6 +1961,94 @@ describe('IgxGrid - Filtering Row UI actions #grid', () => {
19861961 const headerChip = GridFunctions . getFilterChipsForColumn ( 'ProductName' , fix ) ;
19871962 expect ( headerChip . length ) . toBe ( 1 ) ;
19881963 } ) ) ;
1964+
1965+ it ( 'Should commit the input and new chip after focus out and should edit chip without creating new one.' , fakeAsync ( ( ) => {
1966+ // Click date filter chip to show filter row.
1967+ const dateFilterCellChip = GridFunctions . getFilterChipsForColumn ( 'ReleaseDate' , fix ) [ 0 ] ;
1968+ dateFilterCellChip . nativeElement . click ( ) ;
1969+ tick ( 100 ) ;
1970+ fix . detectChanges ( ) ;
1971+
1972+ // Click input to open calendar.
1973+ const filteringRow = fix . debugElement . query ( By . directive ( IgxGridFilteringRowComponent ) ) ;
1974+ const inputDebugElement = filteringRow . query ( By . directive ( IgxInputDirective ) ) ;
1975+ const input = inputDebugElement . nativeElement ;
1976+ input . click ( ) ;
1977+ tick ( 100 ) ;
1978+ fix . detectChanges ( ) ;
1979+
1980+ // Click the today date.
1981+ const outlet = document . getElementsByClassName ( 'igx-grid__outlet' ) [ 0 ] ;
1982+ let calendar = outlet . getElementsByClassName ( 'igx-calendar' ) [ 0 ] ;
1983+ const todayDayItem : HTMLElement = calendar . querySelector ( '.igx-calendar__date--current' ) ;
1984+ todayDayItem . focus ( ) ;
1985+ todayDayItem . click ( ) ;
1986+ grid . filteringRow . onInputGroupFocusout ( ) ;
1987+ tick ( 100 ) ;
1988+ fix . detectChanges ( ) ;
1989+
1990+ // Verify the newly added chip is selected.
1991+ const chip = GridFunctions . getFilterConditionChip ( fix , 0 ) ;
1992+ const chipDiv = chip . querySelector ( '.igx-chip__item' ) ;
1993+
1994+ expect ( chipDiv . classList . contains ( 'igx-chip__item--selected' ) ) . toBe ( true , 'initial chip is committed' ) ;
1995+
1996+ // Focus out
1997+ grid . nativeElement . focus ( ) ;
1998+ grid . filteringRow . onInputGroupFocusout ( ) ;
1999+ tick ( 200 ) ;
2000+ fix . detectChanges ( ) ;
2001+
2002+ expect ( chipDiv . classList . contains ( 'igx-chip__item--selected' ) ) . toBe ( false , 'initial chip is not committed' ) ;
2003+ expect ( input . value ) . toBe ( '' , 'initial input value is present and not committed' ) ;
2004+
2005+ chip . click ( ) ;
2006+ tick ( 200 ) ;
2007+ fix . detectChanges ( ) ;
2008+
2009+ // Open calendar
2010+ input . click ( ) ;
2011+ tick ( 100 ) ;
2012+ fix . detectChanges ( ) ;
2013+
2014+ calendar = outlet . getElementsByClassName ( 'igx-calendar' ) [ 0 ] ;
2015+
2016+ // View years
2017+ const yearView : HTMLElement = calendar . querySelectorAll ( '.igx-calendar-picker__date' ) [ 1 ] as HTMLElement ;
2018+ yearView . click ( ) ;
2019+ tick ( 100 ) ;
2020+ fix . detectChanges ( ) ;
2021+
2022+ // Select the first year
2023+ const firstYear : HTMLElement = calendar . querySelectorAll ( '.igx-calendar__year' ) [ 0 ] as HTMLElement ;
2024+ firstYear . click ( ) ;
2025+ tick ( 100 ) ;
2026+ fix . detectChanges ( ) ;
2027+
2028+ // Select the first day
2029+ const firstDayItem : HTMLElement = calendar . querySelector ( '.igx-calendar__date' ) ;
2030+ firstDayItem . focus ( ) ;
2031+ firstDayItem . click ( ) ;
2032+ grid . filteringRow . onInputGroupFocusout ( ) ;
2033+ tick ( 100 ) ;
2034+ fix . detectChanges ( ) ;
2035+
2036+ expect ( chipDiv . classList . contains ( 'igx-chip__item--selected' ) ) . toBe ( true , 'chip is committed' ) ;
2037+
2038+ // Focus out
2039+ grid . nativeElement . focus ( ) ;
2040+ grid . filteringRow . onInputGroupFocusout ( ) ;
2041+ tick ( 200 ) ;
2042+ fix . detectChanges ( ) ;
2043+ expect ( chipDiv . classList . contains ( 'igx-chip__item--selected' ) ) . toBe ( false , 'chip is selected' ) ;
2044+
2045+ // Check if we still have only one committed chip
2046+ const chipsLength = GridFunctions . getAllFilterConditionChips ( fix ) . length ;
2047+
2048+ expect ( chipsLength ) . toBe ( 1 , 'there is more than one chip' ) ;
2049+ expect ( chipDiv . classList . contains ( 'igx-chip__item--selected' ) ) . toBe ( false , 'chip is not committed' ) ;
2050+ expect ( input . value ) . toBe ( '' , 'input value is present and not committed' ) ;
2051+ } ) ) ;
19892052 } ) ;
19902053
19912054 describe ( 'Integration scenarios' , ( ) => {
0 commit comments