diff --git a/src/jsonobject.ts b/src/jsonobject.ts index 33afe3b406..c91a8bfa10 100644 --- a/src/jsonobject.ts +++ b/src/jsonobject.ts @@ -819,7 +819,7 @@ export class JsonMetadataClass { if (!Helpers.isValueEmpty(propInfo.maxLength)) { prop.maxLength = propInfo.maxLength; } - if (!Helpers.isValueEmpty(propInfo.displayName)) { + if (propInfo.displayName !== undefined) { prop.displayName = propInfo.displayName; } if (!Helpers.isValueEmpty(propInfo.category)) { diff --git a/tests/jsonobjecttests.ts b/tests/jsonobjecttests.ts index d1215f4bf9..a164ea56e1 100644 --- a/tests/jsonobjecttests.ts +++ b/tests/jsonobjecttests.ts @@ -3264,3 +3264,16 @@ QUnit.test("Test showInMultipleColumns prop visibility", function (assert) { assert.ok(prop, "property is here"); assert.equal(prop.isVisible("", column), true, "column is visible"); }); +QUnit.test("Versions & alternative name", function (assert) { + const prop1 = Serializer.addProperty("question", { name: "testProperty1", displayName: "" }); + const prop2 = Serializer.addProperty("question", { name: "testProperty2", displayName: undefined }); + const prop3 = Serializer.addProperty("question", { name: "testProperty3" }); + + assert.strictEqual(prop1.displayName, "", "prop1"); + assert.strictEqual(prop2.displayName, undefined, "prop2"); + assert.strictEqual(prop3.displayName, undefined, "prop3"); + + Serializer.removeProperty("question", "testProperty1"); + Serializer.removeProperty("question", "testProperty2"); + Serializer.removeProperty("question", "testProperty3"); +});