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