Text component not rendering inside ConfirmDialog

Hello all!
It looks very much like a component “Text” has a regression in the latest version Vaadin(24.5.2)
Code example:

@Route("confirm-view")
@CdiComponent
public class ConfirmView extends VerticalLayout {

    @Serial
    private static final long serialVersionUID = 1L;

    @PostConstruct
    public void init() {

        var textButton = new Button("Confirm with Text", e -> {
            ConfirmDialog dialog = new ConfirmDialog();
            dialog.setHeader("Header");
            dialog.setText(new Text("Message"));
            dialog.setCloseOnEsc(true);
            dialog.setConfirmButton(new Button("Ok"));
            dialog.setCancelText("Cancel");
            dialog.setCancelable(true);
            dialog.addCancelListener(event -> dialog.close());
            dialog.open();
        });
        var spanButton = new Button("Confirm with Span", e -> {
            ConfirmDialog dialog = new ConfirmDialog();
            dialog.setHeader("Header");
            dialog.setText(new Span("Message"));
            dialog.setCloseOnEsc(true);
            dialog.setConfirmButton(new Button("Ok"));
            dialog.setCancelText("Cancel");
            dialog.setCancelable(true);
            dialog.addCancelListener(event -> dialog.close());
            dialog.open();
        });
        addClassName("centered-content");

        add(textButton, spanButton, new Text("Text content"));
    }

}

What if you use it without surrounding Text Objet?

dialog.setText("Message");

Are you sure it’s a regression? I think it never worked because “Text” is a special component that does not really resemble a component - but simple text. In your case you want to pass the string value or use a proper holder like span, paragraph, div or other “real” components.

1 Like

In Vaadin version 23.x “Text” component render correct

Sounds like working by “accident” - you might be better off using the “correct” method or components.

Agreed with Knoobie. Text is a text node, which only makes sense in some contexts - something that’s obviously made for displaying text content. Using a wrapper element like Span or Paragraph should be the way to go.

1 Like

Ок, Ок. I was just stating the fact that such changes occurred during the migration. :face_with_diagonal_mouth:

1 Like

Fair point; if you feel like this is something that should still work, feel free to create a GitHub issue about it. Also note that there’s an overload of setText which accepts a plain String, which should be a good choice as well.