Skip to content

Commit

Permalink
#6828 Dropdown is active on Creator design surface (#6829)
Browse files Browse the repository at this point in the history
Fixes #6828
  • Loading branch information
novikov82 authored Aug 30, 2023
1 parent f92c5da commit 759a0bd
Show file tree
Hide file tree
Showing 2 changed files with 19 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 @@ -358,7 +358,7 @@ export class DropdownListModel extends Base {
}

public onClick(event: any): void {
if(this.question.readOnly) return;
if (this.question.readOnly || this.question.isDesignMode) return;
this._popupModel.toggleVisibility();
this.focusItemOnClickAndPopup();
if (this.searchEnabled && !!event && !!event.target) {
Expand Down
18 changes: 18 additions & 0 deletions tests/dropdown_list_model_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -846,3 +846,21 @@ QUnit.test("lazy loading clear value", function (assert) {
assert.equal(dropdownListModel.inputStringRendered, "");
});

QUnit.test("Dropdown should noy be open on click in design mode", (assert) => {
const survey = new SurveyModel(jsonDropdown);
const question = <QuestionDropdownModel>survey.getAllQuestions()[0];
const dropdownListModel = question.dropdownListModel;
assert.ok(dropdownListModel.popupModel);

const list: ListModel = dropdownListModel.popupModel.contentComponentData.model as ListModel;
assert.equal(list.actions.length, 28);
assert.notOk(dropdownListModel.popupModel.isVisible);
dropdownListModel.onClick(new Event("click"));
assert.ok(dropdownListModel.popupModel.isVisible);
dropdownListModel.onClick(new Event("click"));
assert.notOk(dropdownListModel.popupModel.isVisible);
survey.setDesignMode(true);

dropdownListModel.onClick(new Event("click"));
assert.notOk(dropdownListModel.popupModel.isVisible);
});

0 comments on commit 759a0bd

Please sign in to comment.