@@ -890,6 +890,75 @@ describe("Events", () => {
890
890
cy . get ( "ui5-search-item" )
891
891
. should ( "not.exist" )
892
892
} ) ;
893
+
894
+ it ( "should deselect items when backspace or delete key is pressed" , ( ) => {
895
+ cy . mount (
896
+ < Search >
897
+ < SearchItem text = "Item 1" icon = { history } />
898
+ < SearchItem text = "Item 2" icon = { searchIcon } />
899
+ < SearchItem text = "Item 3" icon = { history } />
900
+ </ Search >
901
+ ) ;
902
+
903
+ cy . get ( "[ui5-search]" )
904
+ . shadow ( )
905
+ . find ( "input" )
906
+ . realClick ( ) ;
907
+
908
+ cy . get ( "[ui5-search]" )
909
+ . shadow ( )
910
+ . find ( "input" )
911
+ . realPress ( "I" ) ;
912
+
913
+ cy . get ( "ui5-search-item" ) . eq ( 0 )
914
+ . should ( "have.attr" , "selected" ) ;
915
+
916
+ // Press backspace and verify item is deselected
917
+ cy . get ( "[ui5-search]" )
918
+ . shadow ( )
919
+ . find ( "input" )
920
+ . realPress ( "Backspace" ) ;
921
+
922
+ cy . get ( "ui5-search-item" ) . eq ( 0 )
923
+ . should ( "not.have.attr" , "selected" ) ;
924
+ } ) ;
925
+
926
+ it ( "should handle backspace and delete keys with grouped items" , ( ) => {
927
+ cy . mount (
928
+ < Search >
929
+ < SearchItemGroup headerText = "Group 1" >
930
+ < SearchItem text = "Group 1 Item 1" icon = { history } />
931
+ < SearchItem text = "Group 1 Item 2" icon = { searchIcon } />
932
+ </ SearchItemGroup >
933
+ < SearchItemGroup headerText = "Group 2" >
934
+ < SearchItem text = "Group 2 Item 1" icon = { history } />
935
+ < SearchItem text = "Group 2 Item 2" icon = { searchIcon } />
936
+ </ SearchItemGroup >
937
+ </ Search >
938
+ ) ;
939
+
940
+ cy . get ( "[ui5-search]" )
941
+ . shadow ( )
942
+ . find ( "input" )
943
+ . realClick ( ) ;
944
+
945
+ cy . get ( "[ui5-search]" )
946
+ . shadow ( )
947
+ . find ( "input" )
948
+ . realPress ( "G" ) ;
949
+
950
+ cy . get ( "ui5-search-item" ) . eq ( 0 )
951
+ . should ( "have.attr" , "selected" ) ;
952
+
953
+ // Press backspace and verify item is deselected
954
+ cy . get ( "[ui5-search]" )
955
+ . shadow ( )
956
+ . find ( "input" )
957
+ . realPress ( "Backspace" ) ;
958
+
959
+ cy . get ( "ui5-search-item" ) . eq ( 0 )
960
+ . should ( "not.have.attr" , "selected" ) ;
961
+ } ) ;
893
962
} ) ;
894
963
895
964
describe ( "Accessibility" , ( ) => {
0 commit comments