Skip to content

Commit

Permalink
refactor: remove empty placeholder height (#3209)
Browse files Browse the repository at this point in the history
  • Loading branch information
tomivirkki authored and vaadin-bot committed May 24, 2022
1 parent d90d972 commit 6537148
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.openqa.selenium.WebElement;
import org.openqa.selenium.interactions.Actions;
import com.vaadin.tests.AbstractComponentIT;
import com.vaadin.flow.component.virtuallist.testbench.VirtualListElement;
import com.vaadin.flow.testutil.TestPath;

import elemental.json.JsonArray;
Expand Down Expand Up @@ -68,6 +69,17 @@ public void chuckNorrisFacts() {
validateListSize(findElement(By.id("chuck-norris-facts")), 1000);
}

@Test
public void componentRendererPhysicalItemCount() {
VirtualListElement list = $(VirtualListElement.class)
.id("chuck-norris-facts");
// The count of generated child elements (direct children of type <div>)
long physicalItemCount = list.getPropertyElements("children").stream()
.filter(el -> "div".equals(el.getTagName())).count();
Assert.assertTrue(physicalItemCount > 4);
Assert.assertTrue(physicalItemCount < 10);
}

@Test
public void peopleListWithDataProvider() {
WebElement list = findElement(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,8 +251,7 @@ public void setRenderer(Renderer<T> renderer) {
* placeholders and actual items.
* <p>
* When no placeholder item is set (or when set to <code>null</code>), an
* empty placeholder element is created with <code>100px</code> of width and
* <code>18px</code> of height.
* empty placeholder element is created.
* <p>
* Note: when using {@link ComponentRenderer}s, the component used for the
* placeholder is statically stamped in the list. It can not be modified,
Expand Down Expand Up @@ -317,9 +316,8 @@ private void updateTemplateInnerHtml() {
* placeholder element with a non 0 size to avoid issues when
* scrolling.
*/
placeholderTemplate = "<div style='width:100px;height:18px'></div>";
placeholderTemplate = "<div style='width:100px;'></div>";
} else if (renderer instanceof ComponentRenderer) {
@SuppressWarnings("unchecked")
ComponentRenderer<?, T> componentRenderer = (ComponentRenderer<?, T>) renderer;
Component component = componentRenderer
.createComponent(placeholderItem);
Expand Down

0 comments on commit 6537148

Please sign in to comment.