Skip to content

Commit

Permalink
Set isMobile inside panels when they are in dynamic panels (#7093)
Browse files Browse the repository at this point in the history
Referenced to #5935
  • Loading branch information
novikov82 committed Oct 9, 2023
1 parent eaffc8a commit 4dff2c6
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/question_paneldynamic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -745,10 +745,8 @@ export class QuestionPanelDynamicModel extends Question
}
public setIsMobile(val: boolean) {
super.setIsMobile(val);
(this.panels || []).forEach(panel => panel.elements.forEach(element => {
if(element instanceof Question) {
(element as Question).isMobile = val;
}
(this.panels || []).forEach(panel => panel.getQuestions(true).forEach(question => {
question.setIsMobile(val);
}));
}

Expand Down
38 changes: 38 additions & 0 deletions tests/surveytests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15845,6 +15845,44 @@ QUnit.test("Check survey isMobile is set correctly on adding new question", func
const question = survey.getQuestionByName("q2");
assert.ok(question.isMobile);
});
QUnit.test("Check survey isMobile is set correctly on question in nested dynamic panels", function (assert) {
const survey = new SurveyModel({
"logoPosition": "right",
"pages": [
{
"name": "page1",
"elements": [
{
"type": "paneldynamic",
"name": "question1",
"templateElements": [
{
"type": "panel",
"name": "panel1",
"elements": [
{
"type": "text",
"name": "question2"
}
]
}
]
}
]
}
]
});
survey.css = defaultV2Css;
survey.data = {
"question1": [
{}
]
};
assert.notOk(survey.isMobile);
survey.setIsMobile(true);
assert.ok(survey.isMobile);
assert.ok(survey.getQuestionByName("question1").panels[0].getQuestionByName("question2").isMobile);
});
QUnit.test("Set correct activePage on fromSurvey and update buttons visibility", function (assert) {
const survey = new SurveyModel({
"elements": [
Expand Down

0 comments on commit 4dff2c6

Please sign in to comment.