Skip to content

Commit

Permalink
Could not rewrite default value for readOnly property fix #7013 (#7014)
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewtelnov committed Sep 25, 2023
1 parent 78884bd commit 2fada3d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
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

0 comments on commit 2fada3d

Please sign in to comment.