diff --git a/packages/select/src/vaadin-select-base-mixin.js b/packages/select/src/vaadin-select-base-mixin.js index 4a033635b1..38d448eb64 100644 --- a/packages/select/src/vaadin-select-base-mixin.js +++ b/packages/select/src/vaadin-select-base-mixin.js @@ -539,7 +539,9 @@ export const SelectBaseMixin = (superClass) => if (!item) { return false; } - return Boolean(item.hasAttribute('label') ? item.getAttribute('label') : item.textContent.trim()); + const hasText = Boolean(item.hasAttribute('label') ? item.getAttribute('label') : item.textContent.trim()); + const hasChildren = item.childElementCount > 0; + return hasText || hasChildren; } /** @private */ diff --git a/packages/select/test/select.common.js b/packages/select/test/select.common.js index 56968cd15d..65a4ee1aad 100644 --- a/packages/select/test/select.common.js +++ b/packages/select/test/select.common.js @@ -103,6 +103,8 @@ describe('vaadin-select', () => { Disabled A number A boolean + + `, root, @@ -472,6 +474,19 @@ describe('vaadin-select', () => { await nextUpdate(select); expect(valueButton.textContent).to.equal('Select an item'); }); + + it('should not show placeholder for items with label, text content or child elements', async () => { + const emptyItems = [select._items[3], select._items[4]]; + const nonEmptyItems = select._items.filter((item) => !emptyItems.includes(item)); + + for (const item of nonEmptyItems) { + select.opened = true; + await nextRender(); + click(item); + await nextUpdate(select); + expect(valueButton.textContent).not.to.equal('Select an item'); + } + }); }); describe('has-value attribute', () => {