Skip to content

Commit

Permalink
property isVisible doesn't work correctly if layout parameter is emtpy (
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewtelnov authored Oct 2, 2024
1 parent 734562c commit edd6958
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/survey-core/src/jsonobject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ export class JsonObjectProperty implements IObject, IJsonPropertyInfo {
return this.enableIf(this.getOriginalObj(obj));
}
public isVisible(layout: string, obj: any = null): boolean {
let isLayout = !this.layout || this.layout == layout;
let isLayout = !this.layout || !layout || this.layout === layout;
if (!this.visible || !isLayout) return false;
if (!!this.visibleIf && !!obj) {
return this.visibleIf(this.getOriginalObj(obj));
Expand Down
15 changes: 15 additions & 0 deletions packages/survey-core/tests/jsonobjecttests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2145,6 +2145,21 @@ QUnit.test("property.isVisible", function (assert) {
"Property is invisible in flow layout"
);
});
QUnit.test("title property.isVisible", function (assert) {
const prop = Serializer.findProperty("question", "title");
prop.visibleIf = (obj: any): boolean => {
return obj.name != "abc";
};
const q = new QuestionTextModel("q1");
assert.equal(prop.isVisible("row", q), true, "row, #1");
assert.equal(prop.isVisible("detail", q), false, "detail #2");
assert.equal(prop.isVisible("", q), true, "empty #1");
q.name = "abc";
assert.equal(prop.isVisible("row", q), false, "row, #2");
assert.equal(prop.isVisible("detail", q), false, "detail #2");
assert.equal(prop.isVisible("", q), false, "empty #2");
(<any>prop).visibleIf = undefined;
});

QUnit.test("property.baseValue", function (assert) {
Serializer.addProperty("questionbase", {
Expand Down

0 comments on commit edd6958

Please sign in to comment.