Skip to content

Commit

Permalink
Merge pull request #7782 from surveyjs/bugs/7769-focusOnFirstError-br…
Browse files Browse the repository at this point in the history
…icks-dropdown-popup-if-any-errors-are-on-the-same-page

focusOnFirstError bricks dropdown popup if any errors are on the same page
  • Loading branch information
andrewtelnov authored Feb 1, 2024
2 parents 078a54d + bd4db73 commit e63882f
Show file tree
Hide file tree
Showing 2 changed files with 64 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 @@ -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<ItemValue>(visibleItems, _onSelectionChanged, false, undefined, this.question.choicesLazyLoadEnabled ? this.listModelFilterStringChanged : undefined, this.listElementId);
Expand Down
63 changes: 63 additions & 0 deletions testCafe/questions/dropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
});

0 comments on commit e63882f

Please sign in to comment.