Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Grid row's details : RTE displays null instead of a proper value #6826

Open
anasmi opened this issue Nov 18, 2024 · 0 comments
Open

Grid row's details : RTE displays null instead of a proper value #6826

anasmi opened this issue Nov 18, 2024 · 0 comments

Comments

@anasmi
Copy link
Contributor

anasmi commented Nov 18, 2024

Description

When a RichTextEditor used in details of a row, the value set via rte.asDelta().setValue('XY') is ignored and null displayed instead
Note: this seems similar to this task #4551

Expected outcome

RTE has correct value displayed, not null

Minimal reproducible example

@Route(value = "test-view", layout = MainLayout.class)
public class TestView extends FlexBoxLayout {

    record User(String firstName, String lastName) {

    }

    List<User> users = List.of(new User("Julia", "Test"), new User("Bretta", "Test"));

    public static String value = """
        [
          {"insert": "High quality rich text editor for the web\\n", "attributes": {"header":  2}},
          {"insert": "Rich text editor handles the following formatting:\\n"},
          {"insert": "Bold\\n","attributes": { "bold": true, "list": "bullet" }},
          {"insert": "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.\\n", "attributes": { "blockquote": true }},
          {"insert": "Code blocks\\n", "attributes": { "header": 3 }},
          {"insert": "<vaadin-rich-text-editor></vaadin-rich-text-editor>\\n", "attributes": { "code-block": true }}
        ]
        """;

    public TestView() {
        Grid<User> grid = new Grid<>(User.class, false);
        grid.addColumn(User::firstName).setHeader("Name");
        grid.addColumn(User::lastName).setHeader("last name");

        grid.setItemDetailsRenderer(createPersonDetailsRenderer());
        grid.setItems(users);

        add(grid);
    }

    private static ComponentRenderer<PersonDetailsFormLayout, User> createPersonDetailsRenderer() {
        return new ComponentRenderer<>(PersonDetailsFormLayout::new, PersonDetailsFormLayout::setPerson);
    }

    private static class PersonDetailsFormLayout extends FormLayout {
        RichTextEditor editor = new RichTextEditor();

        public PersonDetailsFormLayout() {
            add(editor);

        }

        public void setPerson(User person) {
            editor.asDelta().setValue(TestView.value);
        }
    }
}

Steps to reproduce

  • Add the snippet above
  • Click row to open its details

initial_open

Environment

Vaadin version(s): 24.5.4
OS: windows

Browsers

Chrome

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant