diff --git a/vaadin-combo-box-flow-parent/vaadin-combo-box-flow/src/main/java/com/vaadin/flow/component/combobox/ComboBox.java b/vaadin-combo-box-flow-parent/vaadin-combo-box-flow/src/main/java/com/vaadin/flow/component/combobox/ComboBox.java index 50143345e8a..32e896fd66e 100644 --- a/vaadin-combo-box-flow-parent/vaadin-combo-box-flow/src/main/java/com/vaadin/flow/component/combobox/ComboBox.java +++ b/vaadin-combo-box-flow-parent/vaadin-combo-box-flow/src/main/java/com/vaadin/flow/component/combobox/ComboBox.java @@ -450,4 +450,17 @@ public ComboBoxI18n setRequiredErrorMessage(String errorMessage) { return this; } } + + /** + * Sets the "debounce timeout" that the component waits for a short pause in + * typing, before triggering a server-side visit to filter items. The + * default is 500ms. + * + * @param filterTimeout + * the time in milliseconds that needs to happen between + * keystrokes until filtering is triggered. + */ + public void setFilterTimeout(int filterTimeout) { + getElement().setProperty("filterDebouncerTimer", filterTimeout + ""); + } } diff --git a/vaadin-combo-box-flow-parent/vaadin-combo-box-flow/src/main/resources/META-INF/resources/frontend/comboBoxConnector.js b/vaadin-combo-box-flow-parent/vaadin-combo-box-flow/src/main/resources/META-INF/resources/frontend/comboBoxConnector.js index 3af8ceaea2b..cb3c726bc1f 100644 --- a/vaadin-combo-box-flow-parent/vaadin-combo-box-flow/src/main/resources/META-INF/resources/frontend/comboBoxConnector.js +++ b/vaadin-combo-box-flow-parent/vaadin-combo-box-flow/src/main/resources/META-INF/resources/frontend/comboBoxConnector.js @@ -89,7 +89,11 @@ window.Vaadin.Flow.comboBoxConnector.initLazy = (comboBox) => { if (filterChanged) { cache = {}; lastFilter = params.filter; - this._filterDebouncer = Debouncer.debounce(this._filterDebouncer, timeOut.after(500), () => { + let timerValue = 500; + if (comboBox.filterDebouncerTimer) { + timerValue = comboBox.filterDebouncerTimer; + } + this._filterDebouncer = Debouncer.debounce(this._filterDebouncer, timeOut.after(timerValue), () => { if (serverFacade.getLastFilterSentToServer() === params.filter) { // Fixes the case when the filter changes // to something else and back to the original value