Skip to content

Commit c8e37f1

Browse files
vaadin-botugur-vaadinsissbruecker
authored
fix: make fetching data possible when virtual list is inert (#7727) (#7864)
* test: extract getting items into helper class * fix: make fetching data possible when virtual list is inert --------- Co-authored-by: Ugur Saglam <106508695+ugur-vaadin@users.noreply.github.com> Co-authored-by: Sascha Ißbrücker <sissbruecker@vaadin.com>
1 parent 5420bba commit c8e37f1

File tree

3 files changed

+87
-0
lines changed
  • vaadin-virtual-list-flow-parent

3 files changed

+87
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
* Copyright 2000-2025 Vaadin Ltd.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
5+
* use this file except in compliance with the License. You may obtain a copy of
6+
* the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13+
* License for the specific language governing permissions and limitations under
14+
* the License.
15+
*/
16+
package com.vaadin.flow.component.virtuallist.tests;
17+
18+
import java.util.stream.IntStream;
19+
20+
import com.vaadin.flow.component.html.Div;
21+
import com.vaadin.flow.component.virtuallist.VirtualList;
22+
import com.vaadin.flow.dom.ElementUtil;
23+
import com.vaadin.flow.router.Route;
24+
25+
@Route("vaadin-virtual-list/inert")
26+
public class InertVirtualListPage extends Div {
27+
28+
public InertVirtualListPage() {
29+
var virtualList = new VirtualList<String>();
30+
var items = IntStream.range(0, 10).mapToObj(i -> "Item " + i).toList();
31+
virtualList.setItems(items);
32+
ElementUtil.setInert(virtualList.getElement(), true);
33+
add(virtualList);
34+
}
35+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/*
2+
* Copyright 2000-2025 Vaadin Ltd.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
5+
* use this file except in compliance with the License. You may obtain a copy of
6+
* the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13+
* License for the specific language governing permissions and limitations under
14+
* the License.
15+
*/
16+
package com.vaadin.flow.component.virtuallist.tests;
17+
18+
import org.junit.Assert;
19+
import org.junit.Before;
20+
import org.junit.Test;
21+
import org.openqa.selenium.By;
22+
23+
import com.vaadin.flow.component.virtuallist.testbench.VirtualListElement;
24+
import com.vaadin.flow.testutil.TestPath;
25+
import com.vaadin.tests.AbstractComponentIT;
26+
27+
import elemental.json.JsonType;
28+
29+
@TestPath("vaadin-virtual-list/inert")
30+
public class InertVirtualListIT extends AbstractComponentIT {
31+
32+
private VirtualListElement virtualList;
33+
34+
@Before
35+
public void init() {
36+
open();
37+
var loadingIndicator = findElement(By.className("v-loading-indicator"));
38+
waitUntil(driver -> !loadingIndicator.isDisplayed());
39+
virtualList = $(VirtualListElement.class).waitForFirst();
40+
}
41+
42+
@Test
43+
public void inertVirtualList_itemsAreRendered() {
44+
var items = VirtualListHelpers.getItems(getDriver(), virtualList);
45+
Assert.assertTrue(items.length() > 0);
46+
for (var i = 0; i < items.length(); i++) {
47+
Assert.assertNotEquals(JsonType.NULL, items.get(i).getType());
48+
}
49+
}
50+
}

vaadin-virtual-list-flow-parent/vaadin-virtual-list-flow/src/main/java/com/vaadin/flow/component/virtuallist/VirtualList.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import com.vaadin.flow.component.UI;
3131
import com.vaadin.flow.component.dependency.JsModule;
3232
import com.vaadin.flow.component.dependency.NpmPackage;
33+
import com.vaadin.flow.component.internal.AllowInert;
3334
import com.vaadin.flow.component.virtuallist.paging.PagelessDataCommunicator;
3435
import com.vaadin.flow.data.binder.HasDataProvider;
3536
import com.vaadin.flow.data.provider.ArrayUpdater;
@@ -303,6 +304,7 @@ public void onEnabledStateChanged(boolean enabled) {
303304
setRenderer(renderer);
304305
}
305306

307+
@AllowInert
306308
@ClientCallable(DisabledUpdateMode.ALWAYS)
307309
private void setViewportRange(int start, int length) {
308310
getDataCommunicator().setViewportRange(start, length);

0 commit comments

Comments
 (0)