Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,14 @@
*/
package com.vaadin.flow.component.combobox.test;

import org.junit.Assert;
import java.time.Duration;
import java.time.temporal.ChronoUnit;

import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;

import com.vaadin.flow.component.combobox.testbench.ComboBoxElement;
import com.vaadin.flow.testutil.TestPath;
Expand All @@ -35,7 +39,10 @@ public void lazyComboBoxFilterFirstQuery() {
comboBox.openPopup();

WebElement query = findElement(By.id("query"));
Assert.assertTrue(query.getText().contains("Filter: 1"));
Assert.assertTrue(query.getText().contains("Count: 10"));

WebDriverWait wait = new WebDriverWait(driver,
Duration.of(2, ChronoUnit.SECONDS));
wait.until(ExpectedConditions.textToBePresentInElement(query,
"Filter: 1 Count: 10"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ public abstract class ComboBoxBase<TComponent extends ComboBoxBase<TComponent, T
HasValidationProperties, HasValidator<TValue>, HasPlaceholder {
private static final int DEFAULT_FILTER_TIMEOUT = 500;

private String lastKnownFilter;

/**
* Registration for custom value listeners that disallows entering custom
* values as soon as there are no more listeners for the custom value event
Expand Down Expand Up @@ -346,9 +348,8 @@ public void setAllowCustomValue(boolean allowCustomValue) {
*
* @return the filter string
*/
@Synchronize(property = "filter", value = "filter-changed")
protected String getFilter() {
return getElement().getProperty("filter");
return lastKnownFilter;
}

/**
Expand All @@ -359,7 +360,11 @@ protected String getFilter() {
* @param filter
* the String value to set
*/
@Deprecated
protected void setFilter(String filter) {
lastKnownFilter = filter;
// MT 20250-02-21 I assume client side never uses this, probably the
// whole method is obsolete
getElement().setProperty("filter", filter == null ? "" : filter);
}

Expand Down Expand Up @@ -1367,6 +1372,7 @@ private void confirmUpdate(int id) {
*/
@ClientCallable
private void setViewportRange(int start, int length, String filter) {
this.lastKnownFilter = filter;
dataController.setViewportRange(start, length, filter);
}

Expand Down