Skip to content

Clicking button in Details will cause JavaScript exception on console #2727

Closed

Description

@TatuLund

Vaadin 23.0.0.rc1 and Vaadin 22.0.6

How to reproduce

  • Open attached MasterDetailView
  • Click a row to see details
  • Click the button
  • Check the error in the console

masterdetail:6 There seems to be an error in Vaadin Grid:
Unexpected value for section: details
Please submit an issue to https://github.com/vaadin/flow-components/issues/new/choose
console.error @ masterdetail:6
eval @ FlowBootstrap.js?f80c:67
_onContentFocusIn @ vaadin-grid-keyboard-navigation-mixin.js?709a:734

Code to reproduce

@PageTitle("Master-Detail")
@route(value = "masterdetail")
public class MasterDetailView extends Div {

private Grid<Vector<String>> grid = new Grid<>();

public MasterDetailView() {
	setSizeFull();

	// Configure Grid
	grid.addColumn(item -> item.get(0)).setAutoWidth(true);
	grid.addColumn(item -> item.get(1)).setAutoWidth(true);

	grid.setItems(createData());
	grid.addThemeVariants(GridVariant.LUMO_NO_BORDER);
	grid.setHeightFull();

	grid.setItemDetailsRenderer(createPersonDetailsRenderer());

	add(grid);

}

private List<Vector<String>> createData() {
	Random rand = new Random();
	return IntStream.range(0, 20).mapToObj(i -> {
		Vector<String> vector = new Vector<>(2);
		vector.add("email" + i + "@domain.com");
		vector.add("" + rand.nextInt(20));
		return vector;
	}).collect(Collectors.toList());
}

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

private class PersonDetailsFormLayout extends VerticalLayout {
	private final TextField emailField = new TextField("Email address");
	private final TextField phoneField = new TextField("Phone number");

	public PersonDetailsFormLayout() {
		Stream.of(emailField, phoneField).forEach(field -> {
			add(field);
		});

		Button btn = new Button("do it");
		btn.addClickListener(e -> {
			Notification.show("clicked");
		});
		add(btn);
	}

	public void setPerson(Vector<String> person) {
		emailField.setValue(person.get(0));
		phoneField.setValue(person.get(1));
	}
}

}

Activity

  1. darmro commented on Feb 28, 2022

    @darmro

    image

  2. tomivirkki commented on Feb 28, 2022

    @tomivirkki
    Member

    This is a regression from #822

    The connector expects the eventContext.section to be one of header, body, footer. If the section is details (also a valid value for the event context section), an exception is manually thrown.

  3. self-assigned this
    on Mar 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions