Using Vaadin 14.1.19 in a project called "My Starter Project," I attempted to create a TextArea that supports multiple lines. Initially, everything seemed fine, but upon resizing the TextArea, it failed to adjust the number of visible lines. Here is the code snippet:
package com.packagename.myapp;
import org.springframework.beans.factory.annotation.Autowired;
import com.vaadin.flow.component.html.Div;
import com.vaadin.flow.component.orderedlayout.VerticalLayout;
import com.vaadin.flow.component.textfield.TextArea;
import com.vaadin.flow.router.Route;
import com.vaadin.flow.server.PWA;
@Route(layout = DesktopLayout.class)
@PWA(name = "Project Base for Vaadin Flow with Spring", shortName = "Project Base")
public class MainView extends VerticalLayout {
public MainView(@Autowired MessageBean bean) {
String loremIpsum = "Lorem ipsum dolor sit amet, [....].";
TextArea readOnlyTA = new TextArea();
readOnlyTA.setLabel("Read-only");
readOnlyTA.setWidth("1500px");
readOnlyTA.setMaxWidth("80vw");
readOnlyTA.setValue(loremIpsum);
readOnlyTA.setReadOnly(true);
add(readOnlyTA);
TextArea readWriteTA = new TextArea();
readWriteTA.setLabel("normal");
readWriteTA.setWidth("1500px");
readWriteTA.setMaxWidth("80vw");
readWriteTA.setValue(loremIpsum);
add(readWriteTA);
Div readOnlyDiv = new Div();
readOnlyDiv.setWidth("1500px");
readOnlyDiv.setMaxWidth("80vw");
readOnlyDiv.add(loremIpsum);
add(readOnlyDiv);
}
}
Upon initially opening the view with a wide window, it appears as expected:
https://i.sstatic.net/c7XB8.png
However, resizing the window results in only the beginning of the text being readable within the TextArea components, without scroll functionality.
https://i.sstatic.net/hdr6S.png
Strangely, only the DIV resizes as anticipated.
Is there a way to ensure that Vaadin's TextArea adapts to window resizes?