Skip to content

[card] Text node not shown when passed into default slot #11207

@web-padawan

Description

@web-padawan

Description

Unlike other components e.g. vaadin-badge, in vaadin-card the approach for _c attribute assumes an element, so the attribute isn't set if the content is a text node (e.g. Text component in Flow).

this.toggleAttribute('_c', this.querySelector(':scope > :not([slot])'));

This is problematic especially for add(String text) method in Java - see vaadin/docs#5247

Expected outcome

I would expect the _c attribute to be set if there is a non-empty text node, using e.g. SlotController.

Minimal reproducible example

<vaadin-card>
 This text should be visible!
</vaadin-card>

Steps to reproduce

Add the snippet to the dev page and observe an empty card.

Environment

Vaadin version(s): 24.x, 25.x

Browsers

Issue is not browser related

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions