diff --git a/src/dropdownListModel.ts b/src/dropdownListModel.ts index d74607a7a3..eb6ed44dfc 100644 --- a/src/dropdownListModel.ts +++ b/src/dropdownListModel.ts @@ -400,7 +400,7 @@ export class DropdownListModel extends Base { changeSelectionWithKeyboard(reverse: boolean): void { let focusedItem = this.listModel.focusedItem; if (!focusedItem && this.question.selectedItem) { - if (ItemValue.getItemByValue(this.question.choices, this.question.value)) { + if (ItemValue.getItemByValue(this.question.visibleChoices, this.question.value)) { this.listModel.focusedItem = this.question.selectedItem; } } diff --git a/testCafe/questions/dropdown.js b/testCafe/questions/dropdown.js index d4106c4077..bcbb87d536 100644 --- a/testCafe/questions/dropdown.js +++ b/testCafe/questions/dropdown.js @@ -986,6 +986,29 @@ frameworks.forEach((framework) => { .expect(questionValueInput.value).eql("item20"); }); + test("Check dropdown key press with auto-generated list", async (t) => { + const json = { + focusFirstQuestionAutomatic: true, + questions: [ + { + type: "dropdown", + name: "dropdown", + defaultValue: 2016, + "choicesMin": 2014, + "choicesMax": 2023 + } + ] + }; + await initSurvey(framework, json); + + await t + .pressKey("down") + .pressKey("down") + .pressKey("down") + .pressKey("enter") + .expect(questionValueInput.value).eql("2018"); + }); + test("Check reset focused item - no focus on first popup", async (t) => { const jsonWithDropDown = { questions: [