Skip to content

Commit

Permalink
Fix: Could not override defaultValue for question hideNumber property s…
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewtelnov committed Jul 20, 2021
1 parent ee41dfc commit 021aacf
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/question.ts
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ export class Question extends SurveyElement
* @see titleLocation
*/
public get hideNumber(): boolean {
return this.getPropertyValue("hideNumber", false);
return this.getPropertyValue("hideNumber");
}
public set hideNumber(val: boolean) {
this.setPropertyValue("hideNumber", val);
Expand Down
19 changes: 19 additions & 0 deletions tests/jsonobjecttests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2409,3 +2409,22 @@ QUnit.test("itemvalue enableIf property visibility test", function(assert) {
"We show enableIf for all other properties"
);
});
QUnit.test("Change default value for question.hideNumber", function(assert) {
assert.equal(
new Question("q1").hideNumber,
false,
"By default hideNumber returns false"
);
Serializer.findProperty("question", "hideNumber").defaultValue = true;
assert.equal(
new Question("q1").hideNumber,
true,
"We have override hide number"
);
Serializer.findProperty("question", "hideNumber").defaultValue = undefined;
assert.equal(
new Question("q1").hideNumber,
false,
"We made hideNumber false by default again"
);
});

0 comments on commit 021aacf

Please sign in to comment.