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

[Knockout] When Panel expanded state is set to collapsed, a panel is … #7374

Merged
merged 1 commit into from
Nov 17, 2023
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
2 changes: 1 addition & 1 deletion src/knockout/templates/panel.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<!-- ko template: { name: 'survey-question-errors', data: $data } -->
<!-- /ko -->
<!-- /ko -->
<!-- ko if: state != "collapsed" -->
<!-- ko if: state != "collapsed" || isDesignMode -->
<div
data-bind="style: { paddingLeft: innerPaddingLeft }, css: cssClasses.panel.content, attr: {id:contentId}"
>
Expand Down
3 changes: 1 addition & 2 deletions src/survey-element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -288,8 +288,7 @@ export class SurveyElement<E = any> extends SurveyElementCore implements ISurvey
* @see isExpanded
*/
public get isCollapsed(): boolean {
if (this.isDesignMode) return;
return this.state === "collapsed";
return this.state === "collapsed" && !this.isDesignMode;
}
/**
* Returns `true` if the survey element is expanded.
Expand Down
34 changes: 34 additions & 0 deletions testCafe/questions/panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,3 +170,37 @@ frameworks.forEach((framework) => {
assert.equal(json.title, newTitle);
});
});

frameworks.forEach((framework) => {
fixture`${framework} ${title}`.page`${url}${framework}`.beforeEach(
async (t) => {
await initSurvey(framework, { elements: [{ type: "text", name: "q1" }] }, undefined, true);
}
);

test("Show content for collapsed panel in designer", async (t) => {
const updateSurvey = ClientFunction(() => {
window.survey.setDesignMode(true);
window.survey.fromJSON({
elements: [
{
"type": "panel",
"name": "panel1",
"elements": [
{
"type": "text",
"name": "question1"
}
],
"state": "collapsed"
}
]
});
});
await t
.expect(Selector("span").withText("question1").visible).notOk();
await updateSurvey();
await t
.expect(Selector("span").withText("question1").visible).ok();
});
});