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

Could not rewrite default value for readOnly property fix #7013 #7014

Merged
merged 1 commit into from
Sep 25, 2023
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-element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@ export class SurveyElement<E = any> extends SurveyElementCore implements ISurvey
* @see readOnly
*/
public get isReadOnly(): boolean {
return false;
return this.readOnly;
}
/**
* Makes the survey element read-only.
Expand All @@ -501,7 +501,7 @@ export class SurveyElement<E = any> extends SurveyElementCore implements ISurvey
* @see isReadOnly
*/
public get readOnly(): boolean {
return this.getPropertyValue("readOnly", false);
return this.getPropertyValue("readOnly");
}
public set readOnly(val: boolean) {
if (this.readOnly == val) return;
Expand Down
9 changes: 9 additions & 0 deletions tests/jsonobjecttests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2606,6 +2606,15 @@ QUnit.test("Change question isRequired default value", function (assert) {
Serializer.findProperty("question", "isRequired").defaultValue = false;
assert.equal(new Question("q1").isRequired, false, "It is false again");
});
QUnit.test("Change question readOnly default value", function (assert) {
assert.equal(new Question("q1").readOnly, false, "It is false by defult");
Serializer.findProperty("question", "readOnly").defaultValue = true;
assert.equal(new Question("q1").readOnly, true, "It is true now");
assert.deepEqual(new Question("q1").toJSON(), { name: "q1" }, "no readOnly attribute in JSON, #1");
Serializer.findProperty("question", "readOnly").defaultValue = false;
assert.equal(new Question("q1").readOnly, false, "It is false again");
assert.deepEqual(new Question("q1").toJSON(), { name: "q1" }, "no readOnly attribute in JSON, #2");
});
QUnit.test("Load localizable @property", function (assert) {
Serializer.addClass("new_declared_props", [{
name: "str1",
Expand Down