Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple Textboxes cannot be restored from an existing JSON object us… #9404

Merged
merged 1 commit into from
Feb 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion packages/survey-core/src/question_multipletext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,9 @@ export class QuestionMultipleTextModel extends Question
onSurveyLoad() {
this.editorsOnSurveyLoad();
super.onSurveyLoad();
if(!Helpers.isValueEmpty(this.rows)) {
this.calcVisibleRows();
}
}
setQuestionValue(newValue: any, updateIsAnswered: boolean = true) {
super.setQuestionValue(newValue, updateIsAnswered);
Expand Down Expand Up @@ -649,7 +652,6 @@ export class QuestionMultipleTextModel extends Question
protected onRowCreated(row: MutlipleTextRow) {
return row;
}

private calcVisibleRows() {
const colCount = this.colCount;
const items = this.items;
Expand Down
34 changes: 34 additions & 0 deletions packages/survey-core/tests/question_multipletexttests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,40 @@ QUnit.test("defaultValueExpression executing", (assert) => {
q1.items[1].value = 5;
assert.equal(q1.items[2].editor.value, 15, "Calculated correctly");
});
QUnit.test("Make inputSize invisible by default", (assert) => {
const prop = Serializer.findProperty("multipletext", "inputSize");
assert.strictEqual(prop.visible, false);
});
QUnit.test("mutltipletext fromJSON, bug#9400", (assert) => {
const survey = new SurveyModel({
questions: [
{
type: "multipletext",
name: "q1",
items: [
{
name: "item1"
},
{
name: "item2"
},
{
name: "item3",
defaultValueExpression: "{q1.item1} + {q1.item2}"
}
]
}
]
});
const q1 = <QuestionMultipleTextModel>survey.getQuestionByName("q1");
const q2 = <QuestionMultipleTextModel>survey.currentPage.addNewQuestion("multipletext", "q2");
assert.equal(q2.rows.length, 2 * 2, "rows #1");
const json = q1.toJSON();
delete json["name"];
q2.fromJSON(json);
assert.equal(q2.items.length, 3, "items");
assert.equal(q2.rows.length, 3 * 2, "rows # 2");
});
QUnit.test("Make inputSize invisible by default", (assert) => {
const prop = Serializer.findProperty("multipletext", "inputSize");
assert.strictEqual(prop.visible, false);
Expand Down