Skip to content

Commit

Permalink
work for #7206 keyboard navigation doesn't work for auto-generated li…
Browse files Browse the repository at this point in the history
…st (#7236)

Co-authored-by: OlgaLarina <[email protected]>
  • Loading branch information
OlgaLarina and OlgaLarina authored Oct 26, 2023
1 parent adad851 commit 7ab17e7
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/dropdownListModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down
23 changes: 23 additions & 0 deletions testCafe/questions/dropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: [
Expand Down

0 comments on commit 7ab17e7

Please sign in to comment.