Skip to content

Commit

Permalink
resolve #6492 "Select..." is rendered together with the value in drop…
Browse files Browse the repository at this point in the history
…down
  • Loading branch information
OlgaLarina committed Jul 10, 2023
1 parent 21c07a5 commit c869fe0
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/question_dropdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export class QuestionDropdownModel extends QuestionSelectBase {
this.registerPropertyChangedHandlers(["choicesMin", "choicesMax", "choicesStep"], () => {
this.onVisibleChoicesChanged();
});
this.registerPropertyChangedHandlers(["value", "renderAs", "showOtherItem", "otherText", "placeholder", "choices"], () => {
this.registerPropertyChangedHandlers(["value", "renderAs", "showOtherItem", "otherText", "placeholder", "choices", "visibleChoices"], () => {
this.updateReadOnlyText();
});
this.updateReadOnlyText();
Expand Down
36 changes: 36 additions & 0 deletions tests/questionDropdownTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,42 @@ QUnit.test("readOnlyText default", assert => {
question.value = 2;
assert.equal(question.readOnlyText, "", "use choice text");
});
QUnit.test("readOnlyText visibleChoices changed", assert => {
const json = {
"pages": [
{
"name": "page1",
"elements": [
{
"type": "dropdown",
"name": "q1",
"choices": [
"Item 1",
"Item 2",
"Item 3"
]
},
{
"type": "dropdown",
"name": "q2",
"choices": [
"Item 1",
"Item 2",
"Item 3"
],
"choicesVisibleIf": "{q1} = 'Item 1'"
}
]
}
],
};
const survey = new SurveyModel(json);
survey.data = { "q1": "Item 1", "q2": "Item 1" };

const q2 = <QuestionDropdownModel>survey.getQuestionByName("q2");
assert.equal(q2.readOnlyText, "");
assert.equal(q2.selectedItem.id, "Item 1");
});
QUnit.test("readOnlyText render as select", assert => {
const json = {
questions: [
Expand Down

0 comments on commit c869fe0

Please sign in to comment.