File tree Expand file tree Collapse file tree 5 files changed +32
-11
lines changed Expand file tree Collapse file tree 5 files changed +32
-11
lines changed Original file line number Diff line number Diff line change @@ -390,10 +390,10 @@ describe("Properties", () => {
390
390
. should ( "be.visible" ) ;
391
391
} ) ;
392
392
393
- it ( "displays item's delete button on hover" , ( ) => {
393
+ it ( "displays item's delete button on hover if deletable is true " , ( ) => {
394
394
cy . mount (
395
395
< Search >
396
- < SearchItem text = "Item 1" />
396
+ < SearchItem text = "Item 1" deletable />
397
397
< SearchItem text = "Item 2" />
398
398
</ Search >
399
399
) ;
@@ -404,16 +404,26 @@ describe("Properties", () => {
404
404
. realClick ( ) ;
405
405
406
406
cy . realPress ( "I" ) ;
407
+
408
+ cy . get ( "[ui5-search-item]" )
409
+ . eq ( 0 )
410
+ . realHover ( ) ;
407
411
408
412
cy . get ( "[ui5-search-item]" )
413
+ . eq ( 0 )
414
+ . shadow ( )
415
+ . find ( ".ui5-search-item-selected-delete" )
416
+ . should ( "be.visible" ) ;
417
+
418
+ cy . get ( "[ui5-search-item]" )
409
419
. eq ( 1 )
410
420
. realHover ( ) ;
411
421
412
422
cy . get ( "[ui5-search-item]" )
413
423
. eq ( 1 )
414
424
. shadow ( )
415
425
. find ( ".ui5-search-item-selected-delete" )
416
- . should ( "be.visible " ) ;
426
+ . should ( "not.exist " ) ;
417
427
} ) ;
418
428
} ) ;
419
429
@@ -811,7 +821,7 @@ describe("Events", () => {
811
821
}
812
822
cy . mount (
813
823
< Search >
814
- < SearchItem text = "Item 1" icon = { history } onDelete = { onDelete } />
824
+ < SearchItem text = "Item 1" icon = { history } deletable onDelete = { onDelete } />
815
825
</ Search >
816
826
) ;
817
827
Original file line number Diff line number Diff line change @@ -81,6 +81,14 @@ class SearchItem extends ListItemBase {
81
81
@property ( { type : Boolean } )
82
82
selected = false ;
83
83
84
+ /**
85
+ * Defines whether the search item is deletable.
86
+ * @default false
87
+ * @public
88
+ */
89
+ @property ( { type : Boolean } )
90
+ deletable = false ;
91
+
84
92
/**
85
93
* Defines the scope of the search item
86
94
* @default undefined
Original file line number Diff line number Diff line change @@ -43,7 +43,10 @@ export default function SearchFieldTemplate(this: SearchItem) {
43
43
44
44
< span part = "subtitle" class = "ui5-search-item-description" > { this . description } </ span >
45
45
</ div >
46
- < Button class = "ui5-search-item-selected-delete" design = { ButtonDesign . Transparent } icon = { decline } onClick = { this . _onDeleteButtonClick } > </ Button >
46
+
47
+ { this . deletable &&
48
+ < Button class = "ui5-search-item-selected-delete" design = { ButtonDesign . Transparent } icon = { decline } onClick = { this . _onDeleteButtonClick } > </ Button >
49
+ }
47
50
</ div >
48
51
</ div >
49
52
</ li >
Original file line number Diff line number Diff line change 24
24
flex : 1 ;
25
25
}
26
26
27
- .ui5-search-item-selected-delete {
27
+ : host ([ desktop ]) .ui5-search-item-selected-delete {
28
28
display : none;
29
29
}
30
30
31
- : host ([selected ]: hover ),
32
- : host (: focus-within ),
33
- : host (: hover ) {
31
+ : host (: hover ),
32
+ : host (: focus-within ) {
34
33
.ui5-search-item-selected-delete {
35
34
display : inline-block;
36
35
}
Original file line number Diff line number Diff line change 33
33
< ui5-search show-clear-icon >
34
34
< ui5-search-message-area slot ="messageArea " description ="You can try the following " text ="Oh, there are no results "> </ ui5-search-message-area >
35
35
36
+ < ui5-search-item text ="List Item Deletable " icon ="history " deletable > </ ui5-search-item >
36
37
< ui5-search-item text ="List Item " icon ="history " > </ ui5-search-item >
37
- < ui5-search-item text ="List Item " icon ="history " > </ ui5-search-item >
38
- < ui5-search-item text ="List Item " icon ="history " > </ ui5-search-item >
38
+ < ui5-search-item text ="List Item Deletable " icon ="history " deletable > </ ui5-search-item >
39
39
< ui5-search-item text ="List Item " icon ="history " > </ ui5-search-item >
40
40
< ui5-search-item text ="List Item " icon ="globe " > </ ui5-search-item >
41
41
< ui5-search-item text ="List Item " icon ="globe " > </ ui5-search-item >
296
296
const searchItem = document . createElement ( 'ui5-search-item' ) ;
297
297
searchItem . text = item . name ;
298
298
searchItem . icon = 'search' ;
299
+ searchItem . deletable = true ;
299
300
searchItem . addEventListener ( 'ui5-delete' , onDelete ) ;
300
301
parent . appendChild ( searchItem ) ;
301
302
} ) ;
You can’t perform that action at this time.
0 commit comments