Skip to content

Commit

Permalink
Fixed #6993 - Mobile: Incorrect question content paddings on design-s…
Browse files Browse the repository at this point in the history
…urface (#6994)

* Fixed #6993 - Mobile: Incorrect question content paddings on design-surface

* Work for #6993 - Mobile: Incorrect question content paddings on design-surface - added tests

---------

Co-authored-by: tsv2013 <tsv2013@noreply.github.com>
  • Loading branch information
tsv2013 and tsv2013 committed Sep 22, 2023
1 parent a9afd00 commit 29ca7ad
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 6 deletions.
7 changes: 2 additions & 5 deletions src/question.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,9 @@ export class Question extends SurveyElement<Question>
}
public setIsMobile(val: boolean) {
this.isMobile = val && (this.allowMobileInDesignMode() || !this.isDesignMode);
this.renderMinWidth = !val;
}
@property({
defaultValue: false, onSet: (val, target) => {
target.renderMinWidth = !val;
}
}) isMobile: boolean;
@property({ defaultValue: false }) isMobile: boolean;
@property() forceIsInputReadOnly: boolean;

constructor(name: string) {
Expand Down
4 changes: 4 additions & 0 deletions tests/surveytests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15823,12 +15823,16 @@ QUnit.test("Check survey isMobile in design mode", function (assert) {
const textQuestion = survey.getQuestionByName("q1");
const multipleTextQuestion = survey.getQuestionByName("q2");
const checkboxQuestion = survey.getQuestionByName("q3");
assert.ok(textQuestion.renderMinWidth);
survey.setIsMobile(true);
assert.ok(survey._isMobile);
assert.notOk(survey.isMobile);
assert.notOk(textQuestion.isMobile);
assert.notOk(textQuestion.renderMinWidth);
assert.ok(multipleTextQuestion.isMobile);
assert.notOk(multipleTextQuestion.renderMinWidth);
assert.ok(checkboxQuestion.isMobile);
assert.notOk(checkboxQuestion.renderMinWidth);
});
QUnit.test("Check survey isMobile is set correctly on adding new question", function (assert) {
const survey = new SurveyModel({
Expand Down
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion visualRegressionTests/tests/defaultV2/file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ frameworks.forEach(framework => {
(window as any).survey.getAllQuestions()[0].resizeObserver.disconnect();
(window as any).survey.getAllQuestions()[0].processResponsiveness = () => { };
(window as any).survey.getAllQuestions()[0].pageSize = 1;
(window as any).survey.getAllQuestions()[0].isMobile = true;
(window as any).survey.getAllQuestions()[0].setIsMobile(true);
})();
await t.setFilesToUpload(Selector(".sd-file input"), ["files/SingleImage.jpg"]);
const questionRoot = Selector(".sd-question");
Expand Down
45 changes: 45 additions & 0 deletions visualRegressionTests/tests/defaultV2/panel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -589,4 +589,49 @@ frameworks.forEach(framework => {
await takeElementScreenshot("panel-with-errors-without-title.png", panelRoot, t, comparer);
});
});
test("Check question min size inside panels in design mode", async (t) => {
if (framework == "vue") return;
await wrapVisualTest(t, async (t, comparer) => {
await t.resizeWindow(350, 800);
await initSurvey(framework, {
"pages": [
{
"name": "page1",
"elements": [
{
"type": "panel",
"name": "panel1",
"elements": [
{
"type": "panel",
"name": "panel2",
"elements": [
{
"type": "panel",
"name": "panel3",
"elements": [
{
"type": "text",
"name": "question1"
}
]
}
]
}
]
}
]
}
]
});
const panelRoot = Selector(".sd-body");
await ClientFunction(() => {
(window as any).survey.setDesignMode(true);
(window as any).survey.setIsMobile(true);
})();
await resetFocusToBody();

await takeElementScreenshot("responsive-question-inside-panels-in-creator.png", panelRoot, t, comparer);
});
});
});

0 comments on commit 29ca7ad

Please sign in to comment.