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

properties visibility for single component from inheritBaseProps don'… #7726

Merged
merged 1 commit into from
Jan 24, 2024
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
7 changes: 6 additions & 1 deletion src/jsonobject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,12 @@ export class JsonObjectProperty implements IObject {
public isVisible(layout: string, obj: any = null): boolean {
let isLayout = !this.layout || this.layout == layout;
if (!this.visible || !isLayout) return false;
if (!!this.visibleIf && !!obj) return this.visibleIf(obj);
if (!!this.visibleIf && !!obj) {
if (obj.getOriginalObj) {
obj = obj.getOriginalObj() || obj;
}
return this.visibleIf(obj);
}
return true;
}
public get visible(): boolean {
Expand Down
4 changes: 4 additions & 0 deletions src/question_custom.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Question, IConditionObject } from "./question";
import { Serializer, CustomPropertiesCollection, JsonObjectProperty } from "./jsonobject";
import { Base } from "./base";
import {
ISurveyImpl,
ISurveyData,
Expand Down Expand Up @@ -717,6 +718,9 @@ export class QuestionCustomModel extends QuestionCustomModelBase {
public getDynamicType(): string {
return this.questionWrapper ? this.questionWrapper.getType() : "question";
}
public getOriginalObj(): Base {
return this.questionWrapper;
}
protected createWrapper(): void {
this.questionWrapper = this.createQuestion();
this.createDynamicProperties(this.questionWrapper);
Expand Down
3 changes: 3 additions & 0 deletions tests/question_customtests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2796,6 +2796,9 @@ QUnit.test("single component: inheritBaseProps: array<string> #2", function (ass
assert.equal(q1.placeholder, "cde", "q1.placeholder #3");
assert.equal(content.placeholder, "cde", "content.placeholder #3");

const prop = Serializer.getOriginalProperty(q1, "placeholder");
assert.equal(prop.name, "placeholder", "prop.className is correct");
assert.equal(prop.isVisible("form", q1), true, "it is visible");
ComponentCollection.Instance.clear();
});
QUnit.test("single component: inheritBaseProps: true", function (assert) {
Expand Down
Loading