File tree Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -550,7 +550,9 @@ export const SelectBaseMixin = (superClass) =>
550
550
if ( ! item ) {
551
551
return false ;
552
552
}
553
- return Boolean ( item . hasAttribute ( 'label' ) ? item . getAttribute ( 'label' ) : item . textContent . trim ( ) ) ;
553
+ const hasText = Boolean ( item . hasAttribute ( 'label' ) ? item . getAttribute ( 'label' ) : item . textContent . trim ( ) ) ;
554
+ const hasChildren = item . childElementCount > 0 ;
555
+ return hasText || hasChildren ;
554
556
}
555
557
556
558
/** @private */
Original file line number Diff line number Diff line change @@ -103,6 +103,8 @@ describe('vaadin-select', () => {
103
103
< vaadin-item value ="v4 " disabled > Disabled</ vaadin-item >
104
104
< vaadin-item value ="5 "> A number</ vaadin-item >
105
105
< vaadin-item value ="false "> A boolean</ vaadin-item >
106
+ < vaadin-item label ="foo "> </ vaadin-item >
107
+ < vaadin-item > < img src ="data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs= " alt ="" /> </ vaadin-item >
106
108
</ vaadin-list-box >
107
109
` ,
108
110
root ,
@@ -472,6 +474,19 @@ describe('vaadin-select', () => {
472
474
await nextUpdate ( select ) ;
473
475
expect ( valueButton . textContent ) . to . equal ( 'Select an item' ) ;
474
476
} ) ;
477
+
478
+ it ( 'should not show placeholder for items with label, text content or child elements' , async ( ) => {
479
+ const emptyItems = [ select . _items [ 3 ] , select . _items [ 4 ] ] ;
480
+ const nonEmptyItems = select . _items . filter ( ( item ) => ! emptyItems . includes ( item ) ) ;
481
+
482
+ for ( const item of nonEmptyItems ) {
483
+ select . opened = true ;
484
+ await nextRender ( ) ;
485
+ click ( item ) ;
486
+ await nextUpdate ( select ) ;
487
+ expect ( valueButton . textContent ) . not . to . equal ( 'Select an item' ) ;
488
+ }
489
+ } ) ;
475
490
} ) ;
476
491
477
492
describe ( 'has-value attribute' , ( ) => {
You can’t perform that action at this time.
0 commit comments