This is a nice plugin and easy to use. Thank you for creating it. I ran i

This is a nice plugin and easy to use. Thank you for creating it.

I ran into an issue when configuring a grid in the background. When I add a header row to the grid, the columns display in the wrong order. I confirmed when I use raw vaadin calls, the columns are displayed correctly.

Here is a simple example, based off the Vaadin Simple App project, showing the problem. I’m using vaadin 13.0.0. Do you see any problems with the code?

I also attached the mvn project for reference.

	@Override
	protected void onAttach(AttachEvent attachEvent) {
		super.onAttach(attachEvent);
		getUI().ifPresent(ui -> ui.getPushConfiguration().setPushMode(PushMode.AUTOMATIC));
		vaadinAccess();
		pluginAccess();
	}

	private void pluginAccess() {
		AsyncManager.register(this, asyncTask -> {
			asyncTask.push(() -> {
				configureTable(grid2);
			});
		});
	}

	private void vaadinAccess() {
		new Thread() {
			@Override
			public void run() {
				grid1.getUI().ifPresent(ui -> {
					ui.access(() -> {
						configureTable(grid1);
					});
				});
			}

		}.start();
	}

	private static void configureTable(Grid<String[]> grid) {
		for (int i = 0; i < 50; i++) {
			grid.addColumn(t -> "value").setHeader(i + " - Category");
		}

		List<HeaderCell> h1 = grid.appendHeaderRow().getCells();
		for (HeaderCell cell : h1) {
			cell.setComponent(new Span("h1 col"));
		}

		grid.setItems(new String[5]
);
	}
}

17555518.zip (18.3 KB)

Interestingly enough, sometimes I observe the same behaviour for normal ui.access approach (vaadinAccess()) in your snippet. And if you add Thread.sleep(100) before grid1.getUI().ifPresent(ui -> {, it will fail 100% of time.

I’ve created a issue here: https://github.com/vaadin/vaadin-grid-flow/issues/579

Good find. Thanks for creating a bug report.