From bd4db734408de98ee9e45aad8774f9138e1ab37a Mon Sep 17 00:00:00 2001 From: OlgaLarina Date: Thu, 1 Feb 2024 10:06:25 +0300 Subject: [PATCH] resolve #7769 focusOnFirstError bricks dropdown popup if any errors are on the same page --- src/dropdownListModel.ts | 2 +- testCafe/questions/dropdown.js | 63 ++++++++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+), 1 deletion(-) diff --git a/src/dropdownListModel.ts b/src/dropdownListModel.ts index 3be103af52..37be36a0d5 100644 --- a/src/dropdownListModel.ts +++ b/src/dropdownListModel.ts @@ -157,7 +157,7 @@ export class DropdownListModel extends Base { _onSelectionChanged = (item: IAction) => { this.question.value = item.id; if (this.question.searchEnabled) this.applyInputString(item as ItemValue); - this._popupModel.toggleVisibility(); + this.popupModel.isVisible = false; }; } const res = new ListModel(visibleItems, _onSelectionChanged, false, undefined, this.question.choicesLazyLoadEnabled ? this.listModelFilterStringChanged : undefined, this.listElementId); diff --git a/testCafe/questions/dropdown.js b/testCafe/questions/dropdown.js index fa9b3f2534..21832c9bcf 100644 --- a/testCafe/questions/dropdown.js +++ b/testCafe/questions/dropdown.js @@ -2068,4 +2068,67 @@ frameworks.forEach((framework) => { .expect(Selector(".sd-boolean__thumb-text").withText("Yes").visible).ok() .expect(popupContainer.visible).notOk(); }); + + test.page(`${url_test}${theme}/${framework}`)("focusOnFirstError bricks dropdown popup if any errors are on the same page", async (t) => { + await t.resizeWindow(800, 600); + const json = { + pages: [ + { + name: "Seite1", + elements: [ + { + type: "dropdown", + name: "Anrede", + title: "Anrede", + choices: [ + { + value: "Item 1", + text: "Frau", + }, + { + value: "Item 2", + text: "Herr", + }, + { + value: "Item 3", + text: "keine Angabe", + }, + { + value: "Item 4", + text: "Divers", + }, + { + value: "Item 5", + text: "Firma", + }, + ], + }, + { + type: "text", + name: "Nachname", + title: "Nachname", + isRequired: true, + }, + ], + }, + ], + focusOnFirstError: true, + }; + await initSurvey(framework, json, { + "onValueChanged": (surveyModel) => { surveyModel.hasErrors(false, true); } + }); + + const questionDropdownV2Select = Selector(".sd-dropdown"); + const popupContainer = Selector(".sv-popup__container").filterVisible(); + const textQuestion = Selector(".sd-input.sd-text"); + await t + .expect(textQuestion.focused).notOk() + + .click(questionDropdownV2Select) + .expect(popupContainer.visible).ok() + + .click(getListItemByText("Herr")) + .expect(textQuestion.focused).ok() + .expect(popupContainer.visible).notOk(); + }); }); \ No newline at end of file