From 7ab17e7b5f1aab1f54b84100c580b4e9e4224bf4 Mon Sep 17 00:00:00 2001 From: OlgaLarina Date: Thu, 26 Oct 2023 18:19:46 +0300 Subject: [PATCH] work for #7206 keyboard navigation doesn't work for auto-generated list (#7236) Co-authored-by: OlgaLarina --- src/dropdownListModel.ts | 2 +- testCafe/questions/dropdown.js | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) 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: [