GridContextMenu 组件未显示在 Dialog 中(Vaadin 24.0.5)

问题描述 投票:0回答:0

我在从 Vadin 23 升级到 Vadin 24 时遇到问题。 不显示 GridContextMenu 组件(在 Dialog 中为 Grid 创建)。 没有错误。

环境:

os: Windows 10 Pro (21H2)
browser: chrome-113.0.5672.93, firefox-113.0.1
java: 17.0.3
nodejs: 18.16.0
spring-boot: 3.0.6
vaadin: 24.0.5

例子:

import com.vaadin.flow.component.dialog.Dialog;
import com.vaadin.flow.component.grid.Grid;
import com.vaadin.flow.component.grid.contextmenu.GridContextMenu;
import com.vaadin.flow.component.html.Div;
import com.vaadin.flow.component.html.Label;
import com.vaadin.flow.router.PageTitle;
import com.vaadin.flow.router.Route;

import java.util.List;

@PageTitle("Example-01")
@Route(value = "example01", layout = MainLayout.class)
public class Example01View extends Div {

    public Example01View() {
        add(createGrid());             // GridContextMenu is displayed

        Dialog dialog = new Dialog();
        dialog.add(createGrid());      // GridContextMenu is not displayed

        dialog.open();
    }

    private Grid<Product> createGrid() {
        Grid<Product> grid = new Grid<>(Product.class, false);
        grid.addColumn(Product::id).setHeader("Id");
        grid.addColumn(Product::name).setHeader("Name");

        GridContextMenu<Product> menu = grid.addContextMenu();
        menu.addItem(new Label("Text 1"));
        menu.addItem(new Label("Text 2"));

        grid.setItems(List.of(
                new Product(1L, "name1"),
                new Product(2L, "name2")
        ));

        return grid;
    }

    public record Product(Long id, String name) {
    }
}

问题未复现于:

  • Vaadin 22.0.x + Spring Boot 2.5.x
  • Vaadin 23.3.x + Spring Boot 2.7.x

为什么它不再起作用了?如何解决这个问题?

感谢您的帮助。

vaadin vaadin-flow vaadin24
© www.soinside.com 2019 - 2024. All rights reserved.