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

Bug/6639 panel dynamic nested footer css #6969

Merged
merged 2 commits into from
Sep 18, 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
21 changes: 8 additions & 13 deletions src/panel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1758,17 +1758,8 @@ export class PanelModel extends PanelModelBase implements IElement {
}
private footerToolbarValue: ActionContainer;

private footerToolbarCssValue: string;

public set footerToolbarCss(val: string) {
this.footerToolbarCssValue = val;
}

public get footerToolbarCss(): string {
return this.footerToolbarCssValue || this.cssClasses.panel?.footer;
}
public onGetFooterActionsCallback: () => Array<IAction>;

public onGetFooterToolbarCssCallback: () => string;
public getFooterToolbar(): ActionContainer {
if (!this.footerToolbarValue) {
var actions = this.footerActions;
Expand All @@ -1786,9 +1777,13 @@ export class PanelModel extends PanelModelBase implements IElement {
actions = this.survey?.getUpdatedPanelFooterActions(this, actions);
}
this.footerToolbarValue = this.createActionContainer(this.allowAdaptiveActions);
// if (!!this.cssClasses.panel) {
this.footerToolbarValue.containerCss = this.footerToolbarCss;
// }
let footerCss = this.onGetFooterToolbarCssCallback ? this.onGetFooterToolbarCssCallback() : "";
if(!footerCss) {
footerCss = this.cssClasses.panel?.footer;
}
if(footerCss) {
this.footerToolbarValue.containerCss = footerCss;
}
this.footerToolbarValue.setItems(actions);
}
return this.footerToolbarValue;
Expand Down
2 changes: 1 addition & 1 deletion src/question_paneldynamic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1769,7 +1769,7 @@ export class QuestionPanelDynamicModel extends Question
panel.onGetFooterActionsCallback = () => {
return this.getPanelActions(panel);
};
panel.footerToolbarCss = this.cssClasses.panelFooter;
panel.onGetFooterToolbarCssCallback = () => { return this.cssClasses.panelFooter; };
panel.registerPropertyChangedHandlers(["visible"], () => {
if(panel.visible) this.onPanelAdded(panel);
else this.onPanelRemoved(panel);
Expand Down
30 changes: 30 additions & 0 deletions tests/question_paneldynamic_tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { ItemValue } from "../src/itemvalue";
import { StylesManager } from "../src/stylesmanager";
import { settings } from "../src/settings";
import { QuestionMatrixModel } from "../src/question_matrix";
import { defaultStandardCss } from "../src/defaultCss/cssstandard";

export default QUnit.module("Survey_QuestionPanelDynamic");

Expand Down Expand Up @@ -6186,4 +6187,33 @@ QUnit.test("nested panel.panelCount&expression question", function (assert) {
assert.equal(panel.getQuestionByName("C").value, 1, "C");
assert.equal(panel.getQuestionByName("D").value, 3, "D");
assert.equal(panel.getQuestionByName("E").value, 3, "E");
});
QUnit.test("Footer css for nested panels", function(assert) {
const footerCss = "abcd";
defaultStandardCss.paneldynamic["panelFooter"] = footerCss;
const survey = new SurveyModel({
questions: [
{
type: "paneldynamic",
name: "q",
panelCount: 1,
templateElements: [
{ type: "text", name: "q1" },
{
type: "paneldynamic",
name: "qq",
panelCount: 1,
templateElements: [{ type: "text", name: "q2" }],
},
],
},
],
});
const question = <QuestionPanelDynamicModel>survey.getQuestionByName("q");
assert.equal(question.panels[0].getFooterToolbar().containerCss, footerCss, "root footer container css");
const nested = <QuestionPanelDynamicModel>question.panels[0].getQuestionByName("qq");
assert.equal(nested.panels[0].getFooterToolbar().containerCss, footerCss, "nested footer container css on loading");
nested.addPanel();
assert.equal(nested.panels[1].getFooterToolbar().containerCss, footerCss, "nested footer container css on creating");
delete defaultStandardCss.paneldynamic["panelFooter"];
});