@@ -2085,6 +2085,71 @@ describe('cascader', () => {
20852085 expect ( testComponent . onChanges ) . toHaveBeenCalledWith ( [ [ 'light' ] ] ) ;
20862086 } ) ) ;
20872087
2088+ it ( 'should support ENTER key to toggle option checked state in multiple mode' , fakeAsync ( ( ) => {
2089+ cascader . componentInstance . setMenuVisible ( true ) ;
2090+ fixture . detectChanges ( ) ;
2091+ tick ( 600 ) ;
2092+ fixture . detectChanges ( ) ;
2093+ getItemAtColumnAndRow ( 1 , 1 ) ! . click ( ) ;
2094+ fixture . detectChanges ( ) ;
2095+ const optionEl = getItemAtColumnAndRow ( 2 , 1 ) ! ;
2096+ const checkboxEl = getCheckboxAtColumnAndRow ( 2 , 1 ) ! ;
2097+ // Initially, the option should not be checked
2098+ expect ( checkboxEl . classList ) . not . toContain ( 'ant-cascader-checkbox-checked' ) ;
2099+ dispatchKeyboardEvent ( cascader . nativeElement , 'keydown' , RIGHT_ARROW ) ;
2100+ fixture . detectChanges ( ) ;
2101+ expect ( optionEl . classList ) . toContain ( 'ant-cascader-menu-item-active' ) ;
2102+ // Press ENTER to toggle the option checked state
2103+ dispatchKeyboardEvent ( cascader . nativeElement , 'keydown' , ENTER ) ;
2104+ fixture . detectChanges ( ) ;
2105+ // The option should now be checked
2106+ expect ( checkboxEl . classList ) . toContain ( 'ant-cascader-checkbox-checked' ) ;
2107+ // Press ENTER again to toggle the option unchecked state
2108+ dispatchKeyboardEvent ( cascader . nativeElement , 'keydown' , ENTER ) ;
2109+ fixture . detectChanges ( ) ;
2110+ // The option should now be unchecked
2111+ expect ( checkboxEl . classList ) . not . toContain ( 'ant-cascader-checkbox-checked' ) ;
2112+ } ) ) ;
2113+
2114+ it ( 'should not activate option with isDisableCheckbox by pressing RIGHT ARROW key' , fakeAsync ( ( ) => {
2115+ cascader . componentInstance . setMenuVisible ( true ) ;
2116+ fixture . detectChanges ( ) ;
2117+ tick ( 600 ) ;
2118+ fixture . detectChanges ( ) ;
2119+ getItemAtColumnAndRow ( 1 , 2 ) ! . click ( ) ;
2120+ fixture . detectChanges ( ) ;
2121+ getItemAtColumnAndRow ( 2 , 1 ) ! . click ( ) ;
2122+ fixture . detectChanges ( ) ;
2123+ // Try to navigate to a disabled checkbox option using keyboard
2124+ dispatchKeyboardEvent ( cascader . nativeElement , 'keydown' , RIGHT_ARROW ) ;
2125+ fixture . detectChanges ( ) ;
2126+ // The option with disableCheckbox should not be activatable via keyboard
2127+ expect ( getItemAtColumnAndRow ( 3 , 1 ) ! . classList ) . not . toContain ( 'ant-cascader-menu-item-active' ) ;
2128+ expect ( getCheckboxAtColumnAndRow ( 3 , 1 ) ! . classList ) . toContain ( 'ant-cascader-checkbox-disabled' ) ;
2129+ // activate item (3, 2)
2130+ expect ( getItemAtColumnAndRow ( 3 , 2 ) ! . classList ) . toContain ( 'ant-cascader-menu-item-active' ) ;
2131+ expect ( getCheckboxAtColumnAndRow ( 3 , 2 ) ! . classList ) . not . toContain ( 'ant-cascader-checkbox-disabled' ) ;
2132+ } ) ) ;
2133+
2134+ it ( 'should not activate option with isDisableCheckbox in moveUpOrDown method' , fakeAsync ( ( ) => {
2135+ cascader . componentInstance . setMenuVisible ( true ) ;
2136+ fixture . detectChanges ( ) ;
2137+ tick ( 600 ) ;
2138+ fixture . detectChanges ( ) ;
2139+ getItemAtColumnAndRow ( 1 , 2 ) ! . click ( ) ;
2140+ fixture . detectChanges ( ) ;
2141+ getItemAtColumnAndRow ( 2 , 1 ) ! . click ( ) ;
2142+ fixture . detectChanges ( ) ;
2143+ getItemAtColumnAndRow ( 3 , 2 ) ! . click ( ) ;
2144+ fixture . detectChanges ( ) ;
2145+ expect ( getItemAtColumnAndRow ( 3 , 2 ) ! . classList ) . toContain ( 'ant-cascader-menu-item-active' ) ;
2146+ // Up key
2147+ dispatchKeyboardEvent ( cascader . nativeElement , 'keydown' , UP_ARROW ) ;
2148+ // The option with disableCheckbox should not be activatable via keyboard
2149+ expect ( getItemAtColumnAndRow ( 3 , 1 ) ! . classList ) . not . toContain ( 'ant-cascader-menu-item-active' ) ;
2150+ expect ( getItemAtColumnAndRow ( 3 , 2 ) ! . classList ) . toContain ( 'ant-cascader-menu-item-active' ) ;
2151+ } ) ) ;
2152+
20882153 describe ( 'should cascade work when the value of ngModel includes nodes that are not existed in options' , ( ) => {
20892154 it ( 'should remove item work' , fakeAsync ( ( ) => {
20902155 setValues ( 2 ) ;
0 commit comments