Skip to content

Virtual List rendering issue in Popover / Dialog with ComponentRenderer #8630

@mukherjeesudebi

Description

@mukherjeesudebi

Description

When a Virtual List is added inside a Popover component and the list is scrolled to end, then on closing and re opening the Popover, the virtual list is blank and appears only when scrolled.

Expected outcome

The Virtual List should appear without the initial scrolling.

Minimal reproducible example

@Route("popover-virtual-list")
public class PopOverVirtualList extends Div {
	public PopOverVirtualList() {

		Button button = new Button(LumoIcon.BELL.create());
		button.addThemeVariants(ButtonVariant.LUMO_ICON);
		button.setAriaLabel("Notifications");

		Popover popover = new Popover();
		popover.setPosition(PopoverPosition.BOTTOM_END);
		popover.setOpenOnClick(true);
		popover.setCloseOnEsc(true);
		popover.setTarget(button);
		popover.setWidth("300px");
		popover.addThemeVariants(PopoverVariant.ARROW, PopoverVariant.LUMO_NO_PADDING);
		popover.setPosition(PopoverPosition.BOTTOM);
		popover.setAriaLabelledBy("notifications-heading");

		List<Person> people = Person.getPeople(500);
		
		VirtualList<Person> virtualList = new VirtualList<>();
		virtualList.setItems(people);
		virtualList.setRenderer(personCardRenderer);
		add(virtualList);
		popover.add(virtualList);

		add(button, popover);

	}

	private ComponentRenderer<Component, Person> personCardRenderer = new ComponentRenderer<>(person -> {
		HorizontalLayout cardLayout = new HorizontalLayout();
		cardLayout.setMargin(true);

		Avatar avatar = new Avatar(person.getFullName(), null);
		avatar.setHeight("64px");
		avatar.setWidth("64px");

		VerticalLayout infoLayout = new VerticalLayout();
		infoLayout.setSpacing(false);
		infoLayout.setPadding(false);
		infoLayout.getElement().appendChild(ElementFactory.createStrong(person.getFullName()));
		infoLayout.add(new Div(new Text("Dummy profession")));

		VerticalLayout contactLayout = new VerticalLayout();
		contactLayout.setSpacing(false);
		contactLayout.setPadding(false);
		contactLayout.add(new Div(new Text("Dummy email")));
		contactLayout.add(new Div(new Text("Dummy phone")));
		infoLayout.add(new Details("Contact information", contactLayout));

		cardLayout.add(avatar, infoLayout);
		return cardLayout;
	});

}

Steps to reproduce

  1. Add the above code to a vaadin 24.6.4 sample project
  2. Click on the bell icon to open the Popover
  3. Scroll to end
  4. Click outside to close the Popover
  5. Click on bell icon to re open the Popover

Environment

Vaadin version(s): 24.6.4

Browsers

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions