Skip to content

Commit

Permalink
work for #5791 Dropdown - Activate a list of options only after a use…
Browse files Browse the repository at this point in the history
…r enters more than the specified number of characters
  • Loading branch information
OlgaLarina committed Jun 20, 2024
1 parent e2d4c17 commit 0041aa9
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions src/dropdownListModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,14 @@ export class DropdownListModel extends Base {
const isUpdate = (this.itemsSettings.skip + 1) < this.itemsSettings.totalCount;
if (!this.itemsSettings.skip || isUpdate) {

if (!!this.filterString && settings.debouncedInputValue > 0) {
if (!!this.filterString && settings.dropdownSearchDelay > 0) {
if (!!this.timer) {
clearTimeout(this.timer);
this.timer = undefined;
}
this.timer = setTimeout(() => {
this.loadQuestionChoices(callbackAfterItemsLoaded);
}, settings.debouncedInputValue);
}, settings.dropdownSearchDelay);
} else {
this.loadQuestionChoices(callbackAfterItemsLoaded);
}
Expand Down
2 changes: 1 addition & 1 deletion src/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ export var settings = {
* This setting applies to all TagBox questions on a page. You can use the [closeOnSelect](https://surveyjs.io/form-library/documentation/api-reference/dropdown-tag-box-model#closeOnSelect) property to specify the same setting for an individual TagBox question.
*/
tagboxCloseOnSelect: false,
debouncedInputValue: 0,
dropdownSearchDelay: 500,
/**
* A function that activates a browser confirm dialog.
*
Expand Down
2 changes: 1 addition & 1 deletion tests/entries/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,4 @@ import "../../src/localization/german";
import { settings } from "../../src/settings";

settings.animationEnabled = false;

settings.dropdownSearchDelay = 0;
8 changes: 4 additions & 4 deletions tests/questionDropdownTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -820,10 +820,10 @@ QUnit.test("lazy loading: several loading", assert => {
}, onChoicesLazyLoadCallbackTimeOut + callbackTimeOutDelta);
});

QUnit.test("lazy loading + change filter string + debouncedInputValue", assert => {
QUnit.test("lazy loading + change filter string + dropdownSearchDelay ", assert => {
const newValueDebouncedInputValue = 2 * onChoicesLazyLoadCallbackTimeOut;
const oldValueDebouncedInputValue = settings.debouncedInputValue;
settings.debouncedInputValue = newValueDebouncedInputValue;
const oldValueDebouncedInputValue = settings.dropdownSearchDelay;
settings.dropdownSearchDelay = newValueDebouncedInputValue;
const done1 = assert.async();
const done2 = assert.async();
const done3 = assert.async();
Expand Down Expand Up @@ -864,7 +864,7 @@ QUnit.test("lazy loading + change filter string + debouncedInputValue", assert =
assert.equal(question.choices.length, 25, "filter is 22 after request");
assert.equal(question.choices[0].value, 22, "filter is 22 after request");

settings.debouncedInputValue = oldValueDebouncedInputValue;
settings.dropdownSearchDelay = oldValueDebouncedInputValue;
done4();
}, onChoicesLazyLoadCallbackTimeOut + newValueDebouncedInputValue);
done3();
Expand Down
8 changes: 4 additions & 4 deletions tests/question_tagbox_tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -384,10 +384,10 @@ QUnit.test("lazy loading: several loading", assert => {
}, onChoicesLazyLoadCallbackTimeOut + callbackTimeOutDelta);
});

QUnit.test("lazy loading + change filter string + debouncedInputValue", assert => {
QUnit.test("lazy loading + change filter string + dropdownSearchDelay ", assert => {
const newValueDebouncedInputValue = 2 * onChoicesLazyLoadCallbackTimeOut;
const oldValueDebouncedInputValue = settings.debouncedInputValue;
settings.debouncedInputValue = newValueDebouncedInputValue;
const oldValueDebouncedInputValue = settings.dropdownSearchDelay;
settings.dropdownSearchDelay = newValueDebouncedInputValue;
const done1 = assert.async();
const done2 = assert.async();
const done3 = assert.async();
Expand Down Expand Up @@ -428,7 +428,7 @@ QUnit.test("lazy loading + change filter string + debouncedInputValue", assert =
assert.equal(question.choices.length, 25, "filter is 22 after request");
assert.equal(question.choices[0].value, 22, "filter is 22 after request");

settings.debouncedInputValue = oldValueDebouncedInputValue;
settings.dropdownSearchDelay = oldValueDebouncedInputValue;
done4();
}, onChoicesLazyLoadCallbackTimeOut + newValueDebouncedInputValue);
done3();
Expand Down

0 comments on commit 0041aa9

Please sign in to comment.