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

Fixed https://github.com/surveyjs/survey-creator/issues/5198 - The Read-Only Survey mode is applied within the Design tab thus it is still possible to edit certain parts of a questionnaire #7828

Merged
merged 1 commit into from
Feb 9, 2024
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: 2 additions & 2 deletions src/survey.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3562,7 +3562,7 @@ export class SurveyModel extends SurveyElementCore
return this.mode == "edit";
}
public get isDisplayMode(): boolean {
return this.mode == "display" || this.state == "preview";
return this.mode == "display" && !this.isDesignMode || this.state == "preview";
}
public get isUpdateValueTextOnTyping(): boolean {
return this.textUpdateMode == "onTyping";
Expand Down Expand Up @@ -4735,7 +4735,7 @@ export class SurveyModel extends SurveyElementCore
.append(this.css.root)
.append(this.css.rootMobile, this.isMobile)
.append(this.css.rootAnimationDisabled, !settings.animationEnabled)
.append(this.css.rootReadOnly, this.mode === "display")
.append(this.css.rootReadOnly, this.mode === "display" && !this.isDesignMode)
.append(this.css.rootCompact, this.isCompact)
.append(this.css.rootFitToContainer, this.fitToContainer)
.toString();
Expand Down
17 changes: 17 additions & 0 deletions tests/surveytests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19285,3 +19285,20 @@ QUnit.test("Advanced header title/description color", function (assert) {
headerModel = headerLayoutElement.data as Cover;
assert.equal(headerModel.headerClasses, "sv-header");
});
QUnit.test("Display mode in design time", function (assert) {
const survey = new SurveyModel();
assert.equal(survey.css.rootReadOnly, "sd-root--readonly");
assert.equal(survey.mode, "edit");
assert.equal(survey.isDisplayMode, false);
assert.equal(survey.getRootCss(), "sd-root-modern");

survey.mode = "display";
assert.equal(survey.mode, "display");
assert.equal(survey.isDisplayMode, true);
assert.ok(survey.getRootCss().indexOf(survey.css.rootReadOnly) !== -1);

survey.setDesignMode(true);
assert.equal(survey.mode, "display");
assert.equal(survey.isDisplayMode, false);
assert.equal(survey.getRootCss(), "sd-root-modern");
});
Loading